Plot colored grid with transparency and overlay

2 次查看(过去 30 天)
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!

回答(1 个)

Chad Greene
Chad Greene 2015-3-30
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.

类别

Help CenterFile Exchange 中查找有关 Mapping Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by