How to generate a non-linear colormap/colorbar?

Viewed 19039

I would like to show a non-uniform colorbar as in the first picture. I have tried the code below. 'mycamp4' is a colormap manually saved. The result is shown as the second figure. The number 0.1 and 1.5 will be too closed too see. How can I make the colorbar like in the first picture?

v = [0.1 1 1.5 5 7.5 10 30];
v_2 = [0.1 1.5 5 7.5 10 30];
contourf(X,Y,pdf_normal',v);
h = colorbar;
load('MyColormaps','mycmap4');
set(gcf,'Colormap',mycmap4);
set(h, 'YTick', v_2)

Picture 1:

enter image description here

Picture 2:

enter image description here

4 Answers

one can try Recolor_contourf. It has two more functions and easy to use. In its help the example given as follows. The function is submitted by me. let me know if face any issue

X=1:10;Y=1:10;
C=rand(10,10)*150;
c=colormap(jet(7));
L=[10 20 50 60 70 100];
[cdd hc]=contourf(X,Y,C,[-5 L]);
Recolor_contourf(hc,c,L,'vert');
Related