Specifying a colormap for values in an array

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

Question: is it important to be able to have the data cursor show the original value, or could the data cursor show arbitrary integers?
I would rather have it show the original value

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 6월 8일

0 개 추천

"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"

카테고리

도움말 센터File Exchange에서 Orange에 대해 자세히 알아보기

질문:

2018년 6월 8일

답변:

2018년 6월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by