Reset to original view for UIAxes control in AppDesigner programmatically

22 次查看(过去 30 天)
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

采纳的回答

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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by