Reputation: 11
I have about 9000 x,y locations, each with a value, say between -1 and 1. Let's call it a temperature.
I would like to plot each point with red/blue proportional to the point's temperature.
I can scale the values, in RGB, from [0 0 1] to [1 0 0] with G=0, and R+B=1. I want to the coldest points, with temperature -1, to be plotted with [0 0 1], pure blue, a mid-level point might be at [.4 0 .6], and a very hot point would be at [.95 0 .5]
I think there's a way to do this with the scatter command, but I can't figure out how to give a different RGB value to each point. If there's a way to do this with a plot command, I'd be happy to do that instead.
I'd appreciate any guidance you can give me.
Thank you,
Phil
Upvotes: 1
Views: 2831
Reputation: 12693
Use the cdata
property:
cdata = [0 0 0;
1 0 0;
0 1 0;
0 0 1;
1 0 1];
figure;
scatter(1:5, 1:5, 'o','cdata',cdata)
Upvotes: 2