Reputation: 6200
Is it possible to color datapoints individually with a single plot command like
plot(X,'color',colors);
Or do I need a loop for that:
for k=1:length(X)
plot(k,X,'.','color',colors(k,:));
hold on
end
Upvotes: 0
Views: 31
Reputation: 8091
Use "scatter". You can specify the color as RGB values or index into a colormap. One example
x = randn (100, 1);
y = randn (100, 1);
c = randi (20, 100, 1);
scatter(x, y, 10, c, ".")
Upvotes: 2