How to stop App Designer resizing UIAxes?

38 ビュー (過去 30 日間)
Peter Valent
Peter Valent 2019 年 3 月 23 日
コメント済み: Ali Shahabi 2022 年 8 月 26 日
I have created a simple APP using the App Designer. It plots a simple graph into an UIAxes object. The problem is that the position of y-axis is moved based on the width of y-labels. In the future the APP will consist of several axes that should be perfectly aligned with the same width of x-axis. See the picture bellow:
I would like to maintain the same position of both the x-axis and y-axis not taking into account the width of the labels. It works when the program is build in GUIDE, however, I would like to make it in App Designer. Is it possible?
See the picture bellow for how it works in GUIDE and what I would like to achieve in App Designer:

採用された回答

Adam Danz
Adam Danz 2019 年 3 月 23 日
編集済み: Adam Danz 2022 年 5 月 25 日
Ideally you would save the inner position of the axis, do the plotting, and then restore the inner axis position. But the 'InnerPosition' property of axes in app designer is read-only (why!?? who knows). So here's a work around.
In your plotting function,
  1. Before plotting, save the original read-only 'InnerPosition' values
  2. Do your plotting
  3. Calculate the difference between the new inner position and old inner position
  4. Change the 'Position' value so that the inner position matches what it used to be.
axInnerPos = app.UIAxes.InnerPosition; %1) store original inner position of axis
% plot() %2) do your plotting, etc.
innerPosDiff = axInnerPos - app.UIAxes.InnerPosition; %3) calculate difference between original and current inner ax pos.
app.UIAxes.Position = app.UIAxes.Position + innerPosDiff; %4) change the 'position' so inner position matches original values
Update: See Mischa Kim's comment below for MATLAB R2020b and later.
  4 件のコメント
Linus Olofsson
Linus Olofsson 2022 年 5 月 25 日
I don't think my uiaxes are resizing, but the title element keeps moving anyways.
When setting the position constraint in my app's start up function, this does not stop the title of my uiaxes from moving and it always appears on top of what I'm plotting. For example, when I'm using the imshowpair() function and display something that is smaller than the original uiaxes, the tile moves with the size of what I'm plotting.
I don't want to show axes or tick marks, but even if I do so, plotting using imshowpair() seems to erase them even if I set the axes, tick marks, grid lines, etc to foreground. Maybe I have other problems?
My attached app will not run as it tries to connect to a server/load large local files, but might show the problem.
Ali Shahabi
Ali Shahabi 2022 年 8 月 26 日
Did you find the solution for the issue?

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by