Reputation: 83
I have a large matrix DAT(50000+,42)
. I am plotting 2 rows of this matrix on the x and y axes, and want the plot points to vary in color due to the value of a separate row. Can anybody advise? pcolor
will not work for me due to "color data input must be a matrix" error.
TIA
X = DAT(:,21);
Y = DAT(:,22);
Z = DAT(:,28);
plot(X,Y,'*');
hold on
pcolor(X,Y,Z);
hold off
Upvotes: 1
Views: 9864
Reputation: 189
You can select the colors from an array generated with colormap
like this:
DAT = randn(30,42);
X = DAT(:,21);
Y = DAT(:,22);
Z = DAT(:,28);
[dummy ID]=sort(Z);
colors=colormap(jet(length(Z)));
figure
for i=1:length(Z)
plot(X(i),Y(i),'*','Color',colors(ID(i),:));
hold on
end
The only issue with this technique is that you cannot do plots with millions of points because of the looped plotting, but otherwise it works like a charm:
Upvotes: 1