Getting different colors for different numbers using `spy` in Matlab

╄→гoц情女王★ 提交于 2019-12-06 03:34:22

Here is how you can do it:

spy(a,'k')
hold on
spy(a==10,'r')
spy(a==9,'b')
hold off

Another way is to use scatter instead of spy :

[x,y] = find(a);
clr = a(a~=0);
scatter(x,y,[],clr)
set(gca,'YDir','rev')

In this case the points will be colored by a values according to current figure colormap.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!