Adjusting the colorbar to zero value

22 次查看(过去 30 天)
Hei,
So I have a problem that is giving me a terrible headache. I have data that I am contouring using CONTOURF. It's ground temperature data. X,Y,Z is Time, Depth, Temp. I know that every time I contour the data I can use the colorbar adjuster to set the colorbar to what I need (which is blue for colds and reds for above zero). Essentially I want to remove the green color and set the transition from blues to reds to be at the zero degree isotherm. Now I tried making a small funtion that would create a colormap that is the color I want, using the min and max values from the Z data. But it just doesn't quite get lined up with the zero degree isotherm. I realized this is because the colorbar uses its own method for determining what values get what colors and it never has zero sitting right on the transition from blues to reds. Does anyone know how to do something along these lines? Or if you have some suggestions I'd appreciate it.
Jordan

回答(1 个)

Grzegorz Knor
Grzegorz Knor 2012-12-6
I'm not sure if I good understand your problem, but maybe caxis function will be helpful:
contourf(peaks+10)
cmap = jet(255);
cmap(:,2) = 0;
colormap(cmap)
caxis([0 18])
colorbar

类别

Help CenterFile Exchange 中查找有关 Purple 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by