How can i print fixed text on UIAxes?

11 ビュー (過去 30 日間)
Alessandro Meda
Alessandro Meda 2022 年 6 月 1 日
編集済み: Voss 2022 年 6 月 6 日
I'm working on an program created with app designer. I used the UIAxes and i wanted to print a couple of information on it, i tried with 'text' but the problem is that the axis of the plot are not always the same so the text will not always be in the same position and most important when i zoom the text move outside the box of the plot.
So is there a way to print something that stays steady (for example top-left) in the plot?

採用された回答

Voss
Voss 2022 年 6 月 1 日
You can set the text's Units to 'normalized' so that the text Position is relative to the axes Position, rather than relative to the axes XLim and YLim.
Example:
ax = axes('XLim',[-2 2],'YLim',[-2 2]);
t = text( ...
'Parent',ax, ...
'String','some text', ...
'Units','normalized', ...
'Position',[0 1]); % top-left
% just for demo, copy stuff to a new figure:
copyobj(gca(),figure())
% now change the axes limits, text stays in top-left:
set(ax,'XLim',[-10 10],'YLim',[50 150])
  7 件のコメント
Voss
Voss 2022 年 6 月 3 日
("Answer" from @Alessandro Meda moved here:)
Thank you, it worked perfectly
Voss
Voss 2022 年 6 月 3 日
編集済み: Voss 2022 年 6 月 6 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by