フィルターのクリア

Reset to original view for UIAxes control in AppDesigner programmatically

22 ビュー (過去 30 日間)
Han Geerligs
Han Geerligs 2024 年 7 月 24 日 14:16
コメント済み: Han Geerligs 2024 年 7 月 25 日 6:18
Hello,
I am trying to programmatically restore the zoom for original view for UIAxes compoinent in AppDesigner.
I'd like to achieve the same as clicking on the 'house' icon at the zoom controls.
Does anyone know how to do this?
--Han
  2 件のコメント
Han Geerligs
Han Geerligs 2024 年 7 月 25 日 6:14
Thanks for your prompt response. The solution in the first link was working for me.
--Han

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

採用された回答

Avni Agrawal
Avni Agrawal 2024 年 7 月 25 日 5:46
I understand that you are trying to reset the original view for a `UIAxes` control in App Designer programmatically. There are two different ways to reset the `UIAxes` in App Designer:
Method 1: Using Auto Limits
When no limit is set, the default behavior is to set the limit to `auto`.
% Button pushed function: Button
function ButtonPushed(app, event)
xlim(app.UIAxes, "auto");
ylim(app.UIAxes, "auto");
end
Method 2: Reset to Original Limits
Reset the limit values based on what they were originally set to when the axis was initialized.
% Store original limits in the startup function
function startupFcn(app)
plot(app.UIAxes, peaks);
app.originalXLim = app.UIAxes.XLim;
app.originalYLim = app.UIAxes.YLim;
end
% Button pushed function: Button
function ButtonPushed(app, event)
xlim(app.UIAxes, app.originalXLim);
ylim(app.UIAxes, app.originalYLim);
end
For a better understanding, please refer to this documentation: https://www.mathworks.com/help/matlab/creating_plots/change-axis-limits-of-graph.html
I hope this helps!
  1 件のコメント
Han Geerligs
Han Geerligs 2024 年 7 月 25 日 6:18
Thanks for your response.
I was in fact looking for the solution "Using Auto Limits".
--Han

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by