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

1 次查看(过去 30 天)
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].

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by