Clear Filters
Clear Filters

Why does zoom unexpectedly invert sometimes? (App Designer, UIFigures)

2 views (last 30 days)
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'};
% 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.

Answers (1)

UDAYA PEDDIRAJU on 14 May 2024
Edited: UDAYA PEDDIRAJU on 14 May 2024
Hi Tiberia,
  • 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.


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!