Azzera filtri
Azzera filtri

Specifying a colormap for values in an array

4 visualizzazioni (ultimi 30 giorni)
Brandon Bush
Brandon Bush il 8 Giu 2018
Risposto: Walter Roberson il 8 Giu 2018
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 Commenti
Walter Roberson
Walter Roberson il 8 Giu 2018
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 il 8 Giu 2018
I would rather have it show the original value

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 8 Giu 2018
"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"

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by