Plot colored grid with transparency and overlay

2 Ansichten (letzte 30 Tage)
Kate
Kate am 27 Mär. 2015
Beantwortet: Chad Greene am 30 Mär. 2015
Hello all,
I'm looking for a way to plot an n x m x 3 matrix to recreate the following type of graph:
the 3rd dimension will be global grids of data which range between 0-1. What I would like to do:
find a plot call where I can plot a global grid of the first dimension (with transparency and a specific color, say red), hold on, and then overly the next dimension and so forth so that I can view a gradient of the combination of all three factors.
If any of you have any ideas about how to approach this I would be very grateful. Thanks!

Antworten (1)

Chad Greene
Chad Greene am 30 Mär. 2015
The simplest way I can think of is to concatenate the three variables as individual RGB values and display as an image like this:
% Some fake data:
[lon,lat] = meshgrid(-179:2:179,89.5:-1:-89.5);
temp = mat2gray(peaks(180)); % mat2gray normalizes 0 to 1
sun = cosd(lat);
water = abs(sind(lon));
% Optional: mask out the ocean:
ocean = ~landmask(lat,lon);
temp(ocean) = NaN;
sun(ocean) = NaN;
water(ocean) = NaN;
% Concatenate 3 variables as rgb:
im = cat(3,temp,sun,water);
% Plot:
worldmap('world')
geoshow(lat,lon,im)
Above I used my landmask function.

Kategorien

Mehr zu Mapping Toolbox finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by