Plot colored grid with transparency and overlay

4 views (last 30 days)
Kate
Kate on 27 Mar 2015
Answered: Chad Greene on 30 Mar 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!

Answers (1)

Chad Greene
Chad Greene on 30 Mar 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.

Categories

Find more on Color and Styling in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!