Adding text below southoutside colorbar labels

3 visualizzazioni (ultimi 30 giorni)
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;

Risposta accettata

Voss
Voss il 14 Mar 2024
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 Commento
Voss
Voss il 14 Mar 2024
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')

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Labels and Annotations in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by