College of Natural Sciences
 
FAQs
This is for IE7 to hold div open

2.6.4. How do I use multiple colormaps?

Here is an example:

% Place a gray PCOLOR of PEAKS and hsv SURF of PEAKS in

% the same plot.

clf

hold off

% Set the colormap

colormap([gray(30);hsv(30)])

% Generate the data

= peaks(30);

% Create the Cdata for the PCOLOR and SURFACE plot.

% The Cdata for each plot should be contiguous, and

% not overlap. This will guarantee that they use

% different regions of the colormap.

cd1 = z + abs(min(min(z)));

cd2 = cd1 + max(max(cd1)) + 1;

% Place the PCOLOR

P = pcolor(cd1);

shading interp

% Change the location so that it will be visible when

% the SURFACE is drawn

set(P,'zdata', -30*ones(size(get(P,'zdata'))))

hold on

% Place the SURFACE plot

S = surf(1:30,1:30,z,cd2);

% Change the location so that it does not overlap the

% PCOLOR

%set(S,'zdata',15+get(S,'zdata'))

% Change the Clim used by AXES

set(gca,'clim',[min(min(cd1)), max(max(cd2))])

% Make sure that the VIEW and AXES limits are correct

view(3)

axis([1 30 1 30 -30 30])

% Rules that you need to follow when doing this.

%

% 1) The Cdata values for each plot should

% not overlap.

%

% 2) The range between the minimum and maximum

% values in Cdata should be the same for each

% plot.

%

% 3) The Cdatas must be contiguous.

%

% 4) Set Clim for AXES to range from the

% smallest and largest values of the 2 Cdatas.