How can I set the colorbar for a specific series of value ?

1 Ansicht (letzte 30 Tage)
wenhao yang
wenhao yang am 25 Aug. 2021
Kommentiert: wenhao yang am 25 Aug. 2021
Just like the color bar in this figure. When I save this figure, the color bar shows (500 1000 1500 2000).
I want the color bar to show like this [300:600:900:1200:1500:1800:2100].

Akzeptierte Antwort

Simon Chan
Simon Chan am 25 Aug. 2021
Adjust the Limits and Ticks as follows:
cb = colorbar
cb.Limits = [300 2100];
cb.Ticks=300:300:2100;
  4 Kommentare
Simon Chan
Simon Chan am 25 Aug. 2021
Then, you need to change the TickLabels as follows:
oldLabel = cb.TickLabels;
cb.TickLabels = cellfun(@(x) sprintf('%.1f',str2double(x)),oldLabel,'UniformOutput',false);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by