Adding text below southoutside colorbar labels
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
John Cruce
el 14 de Mzo. de 2024
Comentada: Voss
el 14 de Mzo. de 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;
0 comentarios
Respuesta aceptada
Voss
el 14 de Mzo. de 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 comentario
Voss
el 14 de Mzo. de 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')
Más respuestas (0)
Ver también
Categorías
Más información sobre Labels and Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!