- Linked Axes: You have 3 linked axes. Consider if "linkaxes" is affecting zoom behavior and test by temporarily disabling it. Try temporarily unlinking them (unlinkaxes) to see if the inversion persists. If it does, the issue might not be related to linked axes.
- Legacy Mode: You're using "enableLegacyExplorationModes". Try disabling it to see if it improves zoom behavior.
- Check Custom Callbacks: You created custom callbacks for zoom actions. Make sure these callbacks aren't accidentally reversing the zoom direction. Ensure there's no logic in "app.zoomPreCallback" and "app.zoomPostCallback" that might invert zoom behavior.
- Update MATLAB: Ensure you're using the latest version of MATLAB, as this might be a bug that has been fixed in a newer release. Try restarting your app or MATLAB to see if it resolves the issue temporarily.
Why does zoom unexpectedly invert sometimes? (App Designer, UIFigures)
2 views (last 30 days)
Show older comments
Hello there!
Sometimes I find the plot zoom behaviour is inverted in my UIFigures. If "zoom in" is active (the "zoom in" symbol in the toolbar is active), it would actually zoom out when clicking in the plot and vice versa. Also, in this case, it is not possible to zoom into only one individual axis.
Unfortunately, this bug is not really reproducable, for it seems to happen out of the blue while using my app.
Similarly, the bug sometimes resolves itself and sometimes I am forced to reopen my app to solve it.
There are no Warnings or Errors.
I work with app designer but create the toolbar for the UIFigure myself, in order to define my own callbacks. Also I have 3 axes which have the xAxis linked:
toolbarButtons = {'export', 'datacursor', 'pan', 'zoomin', 'zoomout', 'restoreview'};
enableLegacyExplorationModes(app.MyUIFigure);
% Toolbar Axis 1
app.axesOne.Toolbar = axtoolbar(app.axesOne, toolbarButtons, 'Visible', 'off');
app.restoreViewBtn = findall(app.axesOne.Toolbar, 'Tooltip','Restore View');
app.restoreViewBtn.ButtonPushedFcn = @app.restoreView;
% Toolbar Axis 2
app.axesTwo.Toolbar = axtoolbar(app.axesTwo, toolbarButtons, 'Visible', 'off');
app.restoreViewBtn(2) = findall(app.axesTwo.Toolbar, 'Tooltip','Restore View');
app.restoreViewBtn(2).ButtonPushedFcn = @app.restoreView;
% Toolbar Axis 3
app.axesThree.Toolbar = axtoolbar(app.axesThree, toolbarButtons, 'Visible', 'off');
app.restoreViewBtn(3) = findall(app.axesThree.Toolbar, 'Tooltip','Restore View');
app.restoreViewBtn(3).ButtonPushedFcn = @app.restoreView;
% Pan Callback
app.panHandle = pan(app.MyUIFigure);
app.panHandle.ActionPreCallback = @app.panPreCallback;
app.panHandle.ActionPostCallback = @app.panPostCallback;
% Zoom Callback
app.zoomHandle = zoom(app.MyUIFigure);
app.zoomHandle.ActionPreCallback = @app.zoomPreCallback;
app.zoomHandle.ActionPostCallback = @app.zoomPostCallback;
% Linking
linkaxes([app.axesOne, app.axesTwo, app.axesThree], 'x');
I already verified, the active toolbar symbol alway reflects correctly in zoom.Direction. So the mess-up must be somewhere elese:
temp = zoom(app.MyUIFigure)
temp =
zoom with properties:
Motion: 'both'
Direction: 'in'
RightClickAction: 'PostContextMenu'
ContextMenu: []
ButtonDownFilter: []
ActionPreCallback: @(varargin)app.zoomPreCallback(varargin{:})
ActionPostCallback: @(varargin)app.zoomPostCallback(varargin{:})
Enable: 'off'
FigureHandle: [1×1 Figure]
UseLegacyExplorationModes: on
Hopefully somebody can point me in the right direction to resolve this mistery. Thanks a lot in advance for any help.
0 Comments
Answers (1)
UDAYA PEDDIRAJU
on 14 May 2024
Edited: UDAYA PEDDIRAJU
on 14 May 2024
Hi Tiberia,
Refer: https://www.mathworks.com/matlabcentral/answers/496325-app-designer-how-to-make-zoom-out-for-my-plot and https://www.mathworks.com/matlabcentral/answers/275827-how-to-zoom-in-out-on-the-figures-in-app-designer. These two queries have a similar and solution, it works for this query as well.
0 Comments
See Also
Categories
Find more on Develop uifigure-Based Apps 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!