MATLAB: Two colormaps on one colorbar: one colormap covering all z data and the other covering a key region

colorbarcolormap

Hi there,
If I have, for example, all my z data varying between 0 to 10 I would like to set the overall colormap (0 to 10) to bone, but a key region, say between2 to 3, set to jet. Finding this pretty hard to do… Thanks…

Best Answer

Here is an example:
% Start by making the colormap
CM = bone(1000);
CM(200:300,:) = jet(101);
colormap(CM) % Set the colormap of the figure
% Now we'll plot some data that goes from 0 to 10.
[X,Y,Z] = peaks(500);
mn = min(Z(:));
R = max(Z(:)) - mn;
Z = (Z + abs(mn))*10/R;
S = surf(X,Y,Z);
set(S,'edgecolor','none','facecolor','interp')
view(61,64)
rotate3d
% Look at view(90,0), the region between z = 2 and z = 3 is jet.
Related Question