How to setup step colorbar in matlab? -
i want change default color bar (jet color) generated matlab, step of color (just figure below). how that?
here's code
[hc hc] = contourf(interp2(sal,2,'spline'),[0:0.5:5]); set(hc,'linestyle','none','ytick',0:4); colorbar;
if looking reduce number of colors in contour plot , colorbar can set new colormap reduce color set.
%get 10 colors jet numcolors = 10; colormap(jet(numcolors)) data = peaks; contourf(data) % optionally can set yticks in conjunction number of items in colormap line colorbar('ytick',linspace(min(data(:)),max(data(:)),numcolors+1))
edit: if want more control on contour lines drawn use function in form countourf(data,v)
v
monotonically increasing vector of desired contour levels. example:
contourf(data,linspace(-7,8,numcolors)) c = colorbar('ytick',linspace(-7,8,numcolors+1));
the draw 10 contour lines @ -7, -5.33, -3.66 ... 8. replace -7 , 8 whatever wish ex. min/max of data or whatever makes sense application
Comments
Post a Comment