Automatic positioning of text on the chart

34 ビュー (過去 30 日間)
Anton Tayurov
Anton Tayurov 2023 年 1 月 16 日
コメント済み: Walter Roberson 2023 年 1 月 16 日
Hello, I often rearrange the schedule and I have to correct the text placement position every time. Is it possible to set its position as, for example, the center of the visible graph window?
Now the text flies out of the visible part of the graph when the limits change
x = 0:100;
y = log10(x);
plot(x, y)
t= text(0.5, 0.5, 'y = log_{10}(x)')
s = t.FontSize;
t.FontSize = 24;

回答 (1 件)

Jiri Hajek
Jiri Hajek 2023 年 1 月 16 日
Hi, you can get the desired behaviour using annotation (see https://www.mathworks.com/help/matlab/ref/annotation.html).
  3 件のコメント
Anton Tayurov
Anton Tayurov 2023 年 1 月 16 日
Please tell me how I can use normalized coordinates?
Walter Roberson
Walter Roberson 2023 年 1 月 16 日
When you call annotation() the position units already default to 'normalized', so you do not need to do anything special: just pass on values that are a fraction of the position of the container being annotated.
Note however that a normalized unit of 0.5 on the width would be relative to the whole axes, not to the drawing area. As your axes labels are often on the left, the middle of the drawing area is typically more than halfway to the right. See also the axes InnerPosition property, which might give you information to calculate the drawing area.

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

カテゴリ

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

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by