필터 지우기
필터 지우기

Specifying a colormap for values in an array

조회 수: 4 (최근 30일)
Brandon Bush
Brandon Bush 2018년 6월 8일
답변: Walter Roberson 2018년 6월 8일
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?
Brandon Bush
Brandon Bush 2018년 6월 8일
I would rather have it show the original value

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

답변 (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