フィルターのクリア

How to rotate the annotation text box?

120 ビュー (過去 30 日間)
BN
BN 2020 年 5 月 3 日
コメント済み: SUAN HU 2023 年 2 月 21 日
I want to rotate my annotation text box so I used both of this codes:
annotation(gcf,'textbox',...
[0.365880952380952 0.219841269841271 0.17102380952381 0.0444444444444446],...
'String','Gulf',...
'FitBoxToText','off','BackgroundColor','none','EdgeColor','none',...
'FontSize',8, 'color','w','FontName', 'cambria math','FontWeight','bold','TextRotation',45);
And:
h = annotation(gcf,'textbox',...
[0.365880952380952 0.219841269841271 0.17102380952381 0.0444444444444446],...
'String','Gulf',...
'FitBoxToText','off','BackgroundColor','none','EdgeColor','none',...
'FontSize',8, 'color','w','FontName', 'cambria math','FontWeight','bold');
set(h,'Rotation',45)
But both of this not working and causing errors. Did you know what is the problem here?
I read both of this questions (1 & 2) but they are didn't work too.
Thanks

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 3 日
You can use textarraw, with options to make the head and line invisible
a = annotation(gcf,'textarrow',...
[0.365880952380952 0.365880952380952], [0.219841269841271 0.219841269841271],...
'String','Gulf', 'HeadStyle', 'none', 'LineStyle', 'none',...
'FontSize',8, 'color','k','FontName', ...
'cambria math','FontWeight','bold', 'TextRotation',45);
  1 件のコメント
SUAN HU
SUAN HU 2023 年 2 月 21 日
Excellent idea !

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

その他の回答 (1 件)

dpb
dpb 2020 年 5 月 3 日
Yes, as both Answers you referred to note specifically you can't rotate an annotation textbox and to use text object or textarrow instead. Both solutions work here; you didn't show or explain what "didn't work, too" means, specifically.
I'd make a minor adjustment to the example of 1) above
plot(1:10)
hAx=gca;
posn=hAx.Position;
angle=atan2d(posn(3),posn(4));
hT=text(5,6,'textbox annotation', 'rotation', angle);
I don't have time at the moment to work out the exact correction to the figure/axes geometry to compute the displayed angle of the line on the axes--the axis height/width is about right but it doesn't account for the area outside of the actual box outlines...

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by