Matlab: colorbar of contourplot only for specified contour levels

64 Views Asked by At

I plotted a contour plot in Matlab with data stored in in A, B and C.

contourf(A,B,C,'LineColor','none')

The data stored in C contains values which are 1, 45, 600 and 1000. So the contour plot has only 4 different contour levels. So far as good.

No my issue: I want to show a colorbar with only the 4 contour levels and only the particular colors for 1, 45, 600 and 1000. Therefore I used the code:

colorbar('Ticks',[1,45,600,1000]);

Unfortunatly, Matlab is now plotting a gradient colorbar from 0 to 1000 (gradient colors) and shows only the ticks defined in the code above at the position between 0 and 1000.

How can I get a colorbar showing only the 4 contour levels without a colorgradient?

Thanks in advance!

I plotted a contour plot and the respective colorbar. I changed different settings of the colorbar but the gradient is still visible.

0

There are 0 best solutions below