How I can do auto-resized axes in App Designer?

27 ビュー (過去 30 日間)
Pavel M
Pavel M 2022 年 2 月 20 日
コメント済み: Ivan Demec 2024 年 10 月 29 日
Hello! I have done app by AppDesigner, and main window (figure) is resized. But Axes with plots dont change their size. How it may be fix?

回答 (2 件)

Lucas Chomey
Lucas Chomey 2023 年 2 月 13 日
Do the command:
axis(app.UIAxes1,"auto"); % UIAxes1 is just the name of the plot window
For auto adjusting the plot window to show all data being plotted.
  2 件のコメント
David
David 2023 年 6 月 30 日
Hello. I have the same problem than Pavel.
The 2 answers does not solve the problem. Concerning "normalise", like Pavel, I don't find these options.
And the solution with axis, doesn't work for this problem because it s not to fit to the data in the uiaxes. The problem is when the uifigure is resized, the uiaxes doesn't resize well.
Thank you all for your reply because I tried lot of things without success.
Ivan Demec
Ivan Demec 2024 年 10 月 29 日
For me Lucas' solution works just fine in v2024b Update1.

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


Rik
Rik 2022 年 2 月 20 日
You should confirm the units property of your axes is set to normalized. If this is not possible you will have to use a listener that will resize the axes when the figure changes size.
  3 件のコメント
David
David 2023 年 6 月 30 日
Hi Linus! I didn't find too these options? Did you find something? Thanks!
Ramanan
Ramanan 2024 年 1 月 11 日
編集済み: Ramanan 2024 年 1 月 12 日
Unfortunately, the app designer UI doesn't provide you with the option to change the units property. Alternatively, you can create a panel in the app designer window and place the UIAxes under the panel. Then in the startup function, add the below commands.
app.UIAxes.Units = "normalized"; % Changes units to scalable
app.UIAxes.Position = [0 0 1 1]; % Position [x,y] = [0,0] and [Xsize,YSize] = [1 1] of the parent object (Panel element)
It worked for me.

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

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by