How can I change number on colorbar caxis?

25 visualizaciones (últimos 30 días)
min wong
min wong el 17 de En. de 2018
Editada: Walter Roberson el 22 de Jul. de 2019
My colorbar is equidistant,
I want to change the colorbar range,be a not equidistant colorbar.
Below is my colorbar.(caxis[(1500,5500)])
I want to change to like below's figure(From Internet).
How can I change the value?
Thank you.

Respuestas (1)

Walter Roberson
Walter Roberson el 17 de En. de 2018
Editada: Walter Roberson el 22 de Jul. de 2019
Record the handle of the colorbar when you create it. Set the Ticks property of the handle to the list of values you want (or possibly YTicks property, depending how old your MATLAB is.)
The way to create a colorbar (or colormap) that is not uniform in step width is to calculate the greatest common divisor (GCD) of the step sizes, and then to repeat colors as many times as (step width divided by GCD). In your example your smallest width is (50-0) = 50, so you would create a table in which the first entry (0 to 50) was the first color, and the next (200-50)/50 = 3 entries were the same second color, and the next (500-200)/50 = 6 entries are the same third color, the 6 entries after that the same fourth color, the (1000-800)/50 = 4 entries after that the same fifth color, the 10 after that the same sixth color, and so on.

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by