Clear Filters
Clear Filters

App designer zoom problems: when i use the zoom the axis position/size change

16 views (last 30 days)
My problem occurs when I zoom using the toolbar on the graph. I want that when I zoom the graph stays fixed in its position. Instead it is not clear why it moves. I tried to change all possible settings but nothing. Please, help me. Thanks!

Accepted Answer

Ayush
Ayush on 20 Jul 2023
Hi MEP
I understand that you don't want the graph to move when you zoom the graph.
In order to resolve the issue please try out the following -
In App Designer, you can use the `axis` function in MATLAB to control the behavior of the graph when zooming. By setting the `axis` limits and mode appropriately, you can ensure that the graph stays fixed in its position when zooming.
1. Open your App Designer project and locate the graph component in the UI.
2. In the "Code View" of App Designer, find the callback function associated with the toolbar zoom action. This function is typically named `zoomButtonValueChanged` or similar.
3. Inside the zoom callback function, add the following code to control the behavior of the graph:
function zoomButtonValueChanged(app, event)
% Get the current axis limits
xLimits = app.GraphName.XLim;
yLimits = app.GraphName.YLim;
% Apply the zoom action
zoom(app.GraphName, event.Value);
% Restore the original axis limits
app.GraphName.XLim = xLimits;
app.GraphName.YLim = yLimits;
% Disable zoom mode to prevent accidental zooming
zoom(app.GraphName, 'off');
end
Replace `GraphName` with the actual name of your graph component in App Designer.
4. Save the changes and run your App Designer application. When you zoom using the toolbar on the graph, the graph should stay fixed in its position.

More Answers (0)

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!