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

12 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Ayush
Ayush el 20 de Jul. de 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.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by