Question

I have a map that contains values from 0 to 1 but also NaN contents. I manage to defined a contour like map with the following code in MATLAB:

imagesc(map)
contourcmap('jet',[-0.3 0 0.3 0.6])
myMap = [[1 1 1]; ...
         [1 0 0]; ... 
         [0 1 0]; ... 
         [0 0 1]];
colormap(myMap);
cbar = colorbar

what I get is a map like this:enter image description` here

however I'd like to show only red,green and blue on the colorbar and get rid of the white range (i.e., [-0.3,0)) but don't want to change the color scale on the main map. is this possible in matlab?

Était-ce utile?

La solution

colorbar is an axes object and as such you can modify its properties, including the color limits. This is done through the 'YLim' property, like this:

colorbar('YLim', [0 0.6]);

Or you can modify this at any time using the object handle:

cbar = colorbar;
set(cbar, 'YLim', [0 0.6]);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top