Clear Filters
Clear Filters

Reset to original view for UIAxes control in AppDesigner programmatically

22 views (last 30 days)
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

Accepted Answer

Avni Agrawal
Avni Agrawal on 25 Jul 2024 at 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!

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!