Adding text below southoutside colorbar labels
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
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
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 Exchange에서 Labels and Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!