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

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

采纳的回答

Ayush
Ayush 2023-7-20
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by