Search code examples
matlabsparse-matrix

Changing display of spy in Matlab


I'm trying to get different elements of a sparse matrix to be different colors (filled in), but it doesn't seem to work with black. But even if I change out black to a different color, I get a weird blurb

spy(A,'ks',3)
markerH = findall(gca,'color','k');
set(markerH,'MarkerFaceColor','k');
hold on
spy(A==10,'gs',3)
markerH = findall(gca,'color','g');
set(markerH,'MarkerFaceColor','g');
hold off

How can I get this to work?


Solution

  • Because other objects like text also may have color property and be black. Use

    markerH = findall(gca,'type','line','color','k');