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
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
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"
See https://www.mathworks.com/matlabcentral/answers/377542-how-can-i-change-number-on-colorbar-caxis#answer_300478 for what you have to do to create a colormap for your situation.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!