MATLAB: How to change colorbar’s color (in some particular value interval)

colorbarcolormapMATLABsurf

Hi , I want to change colorbar's color in some particular value interval.
For example , I likes the jet colorbar , link is my figure, but I want to
let the value between -0.5~ 0.5 to become white color, how can I do this?
thank you much !!

Best Answer

You need to create a new colormap that has the appropriate colors in the appropriate range.
It appears that you have your plot set up to automatically map your minimum data to the lowest color, and your maximum data to the highest color.
I estimate that the range you want to change is roughly 2/3 of the way to the highest color as your range looks like -4 to +2 .
So you need to use something like
newmap = jet; %starting map
ncol = size(newmap,1); %how big is it?
zpos = 1 + floor(2/3 * ncol); %2/3 of way through
newmap(zpos,:) = [1 1 1]; %set that position to white
colormap(newmap); %activate it