Yasmin
Yasmin

Reputation: 951

custom range of colors in colorbar in matlab?

I am trying to have colorbar with specific range. I tried the following

h = colorbar(); 
set(h, 'ylim', [0 60]);

enter image description here

I would like to have the highest value color in 40 to be in 60 in the colorbar (stretching for the colors range), and the color in value 40 in colorbar should be the maximum value in the figure.

Upvotes: 1

Views: 1044

Answers (1)

bla
bla

Reputation: 26069

Before colorbar use the function caxis with the limits you want, for example,

surf(meshgrid(0:7).^2)
caxis([0, 60])
colorbar 

enter image description here

Upvotes: 2

Related Questions