Specifying a colormap for values in an array

2 次查看(过去 30 天)
I am trying to plot some rain gauge data. There are 31 total rain gauges with rainfall totals in a 31x1 array. Each gauge has a Lat and Lon associated with it and the individual data sets are measured over 24hr periods. My issue is that I need to specify certain RGB triples for a specific value or a range of values. ie) orange would be mapped whenever a gauge records 60mm - 62mm of rain for any given day. I used the cmap function and found the colors are in a 64x3 matrix. I wanted to use a for loop to do this and this is the code I have.
Lat = num(:,1);
Lon = num(:,2);
RNFL = num(:,3);
cmap = colormap;
for i = 1:RNFL(end)
plot(Lon,Lat,'Color',[cmap(36,:)])
end
The graph looks like this when plotted:
This is the code I used before and could generate the image below:
Lat = num(:,1);
Lon = num(:,2);
RNFL = num(:,3);
Min = min(RNFL);
Max = max(RNFL);
color = linspace(Min,Max,length(RNFL));
scatter(Lon,Lat,20,RNFL,'filled')
colorbar
The problem with this image is that the colors are not representative of the actual rainfall totals in the dataset.
  2 个评论
Walter Roberson
Walter Roberson 2018-6-8
Question: is it important to be able to have the data cursor show the original value, or could the data cursor show arbitrary integers?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2018-6-8
"I need to specify certain RGB triples for a specific value or a range of values. ie) orange would be mapped whenever a gauge records 60mm - 62mm of rain for any given day"

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by