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
You can customize the colormap and the ticks in the colorbar, but the colorbar itself is based on linear intervals and you can't change that.
There's a workaround though.
lets say you want your colorbar like that in picture 1 with N nonlinear intervals (e.g. color_limits = [1 2 20], if N=2). you have to:
1) define another variable for your data. e.g.
data2 = nan(size(data));
for i=1:N
b = data>color_limits(i) & data>=color_limits(i+1);
data2(b) = i-0.5;
end
Basically you are binning data, using the intervals in color_limits, into a different variable data2 that you will display
2) make your image of data2
3) define the colorbar limits: caxis([0 N])
4) define a colormap with N colors, e.g. colormap(jet(N))
5) customize the ticks in the colorbar