Adding text below southoutside colorbar labels

3 vues (au cours des 30 derniers jours)
John Cruce
John Cruce le 14 Mar 2024
Commenté : Voss le 14 Mar 2024
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;

Réponse acceptée

Voss
Voss le 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 commentaire
Voss
Voss le 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')

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by