A simple question. Is there anyway to tell the Matlab function "contourf", to scale the colors with my given values (and not the dataset's values) ? I know that you can call the function simply by
contourf(x,y,Data, v)
and setting the range in the v vector, but my problem is that Matlab automatically checks whether or not the specified values in the v vector does actually exist in the Data? If they don't exist, then it automatically rescales the color range back to the maximum and minimum available in the dataset.
For instance, if
Data =[0 1 2; 3 4 5; 6 7 8];
v=-10:1:10;
then when I call
contourf(x,y,Data,v)
the colormap shown scales itself with
v=[0:8];
The reason I am asking for this is that I would like to several contour plots for various datasets, but I need to always have the same colorcode associated with the maximum/minimums that might not be necessarily in the current data array passed to the contourf function.
I hope I was clear enough.
Have a look at the caxis
command. I haven't tested it with contourf
, but I think this is what you're after.
Use it like so:
caxis([ cmin cmax ])
where cmin
and cmax
are the minimum and maximum colors given as indices into the current color map. From help caxis
:
CAXIS is a function that sets the axes properties CLim and CLimMode.
meaning you can also tinker with these axes settings manually (i.e., set(gca, 'clim', [...])
)