When zooming in the axes of the app designer, my text will go out of the axes, how to aviod this?

like this. The rectangle represents the axes and the numbers represent text i added, when i zoom in the rectangle, those text will go out of the area instead of disappearing, why? What should i do to avoid this?

 採用された回答

Benjamin Kraus
Benjamin Kraus 2022 年 6 月 1 日
編集済み: Benjamin Kraus 2022 年 6 月 1 日
There is a Clipping property on text objects that is off by default. If you set the Clipping property to 'on' you will get the behavior your are expecting.
Default Behavior
ax = axes;
t = text([0.1 0.2 0.3], [0.1 0.2 0.3], ["one", "two", "three"]);
xlim([0.21 1])
With Clipping 'on'
figure
ax = axes;
t = text([0.1 0.2 0.3], [0.1 0.2 0.3], ["one", "two", "three"],'Clipping','on');
xlim([0.21 1])

4 件のコメント

Voss
Voss 2022 年 6 月 1 日
編集済み: Voss 2022 年 6 月 1 日
@rumin diao: In addition to setting the Clipping property of the texts to 'on', you may want to change the axes property ClippingStyle from its default '3dbox' to 'rectangle'.
Here's the effect that would have in this case:
Clipping 'on' and default ClippingStyle ('3dbox')
figure();
ax = axes;
t = text([0.1 0.2 0.3], [0.1 0.2 0.3], ["one", "two", "three"],'Clipping','on');
xlim([0.21 1])
Clipping 'on' and ClippingStyle 'rectangle'
figure();
ax = axes('ClippingStyle','rectangle');
t = text([0.1 0.2 0.3], [0.1 0.2 0.3], ["one", "two", "three"],'Clipping','on');
xlim([0.21 1])
As you can see, the text 'two' is completely gone when ClippingStyle is '3dbox' because its Position (0.2, 0.2) is outside the axes limits, whereas it is partially shown when ClippingStyle is 'rectangle'.
rumin diao
rumin diao 2022 年 6 月 2 日
thank you!!! this helps me a lot!!
rumin diao
rumin diao 2022 年 6 月 2 日
@Voss wow the display is even better!!! thank you!!!
Voss
Voss 2022 年 6 月 2 日
@rumin diao You're welcome!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAxes Appearance についてさらに検索

タグ

質問済み:

2022 年 6 月 1 日

コメント済み:

2022 年 6 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by