plotting points with different colors
230 ビュー (過去 30 日間)
I have a MxM matrix RegionsMap whose components are integer numbers between 1 and 4. The element RegionsMap(k,j) represents a point in the complex plane, x(k)+i*y(j) (x and y are vectores I previously defined). I want to plot every one of these complex numbers in the complex plane in such a way that: If RegionsMap(k,j) is 1 I color the associated point in blue, if it is 2 I color the associated point in red,...etc (green and yellow for 3 and 4).
How can I achieve this? Any help will be appreciated! Thanks
回答 (2 件)
J. Webster 2016 年 4 月 22 日
something like this maybe?
RegionsMap = randi([1 4],10,10);
x = rand(1,10);
y = rand(1,10);
Walter Roberson 2016 年 4 月 23 日
scatter() fourth parameter can be a vector of values. Create a colormap with as many entries as values you have. caxis([1,n]) where n is the number of entries. Now value K will be drawn with color from entry #K