Adding text below southoutside colorbar labels

3 ビュー (過去 30 日間)
John Cruce
John Cruce 2024 年 3 月 14 日
コメント済み: Voss 2024 年 3 月 14 日
I'm wanting to add a small disclaimer text line under the colorbar of my figure. The figure is a projected map with my colorbar on the bottom outside (southside) and yticklabels underneath. Below is a snippet of code.
What's the cleanest way to add the small text line I'm seeking underneath the yticklabels?
hcb=colorbar('SouthOutside');
set(hcb,'YTick',[-6:0.25:6],'TickLength',[0.01]);
set(hcb,'YTickLabel',{'-6';'';'';'';'-5';'';'';'';'-4';'';'';'';'-3';'';'';'';'-2';'';'';'';'-1';'';'';'';'0';'';'';'';'1';'';'';'';'2';'';'';'';'3';'';'';'';'4';'';'';'';'5';'';'';'';'6'});
hcb.Ruler.TickLabelRotation=0;

採用された回答

Voss
Voss 2024 年 3 月 14 日
caxis([-6 6]) % R2019b
hcb=colorbar('SouthOutside');
set(hcb,'YTick',-6:0.25:6,'TickLength',0.01);
set(hcb,'YTickLabel',{'-6';'';'';'';'-5';'';'';'';'-4';'';'';'';'-3';'';'';'';'-2';'';'';'';'-1';'';'';'';'0';'';'';'';'1';'';'';'';'2';'';'';'';'3';'';'';'';'4';'';'';'';'5';'';'';'';'6'});
hcb.Ruler.TickLabelRotation=0;
ylabel(hcb,'a small disclaimer text line under the colorbar')
  1 件のコメント
Voss
Voss 2024 年 3 月 14 日
By the way, here's a method to set up the colorbar tick labels without having to manually specify all the empty ones:
caxis([-6 6]) % R2019b
hcb=colorbar('SouthOutside');
yt = -6:0.25:6;
ytl = strings(1,numel(yt));
idx = ~rem(yt,1);
ytl(idx) = string(yt(idx));
set(hcb,'YTick',yt,'YTickLabel',ytl,'TickLength',0.01);
hcb.Ruler.TickLabelRotation=0;
ylabel(hcb,'a small disclaimer text line under the colorbar')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by