MATLAB Answers

5

How to zoom in/out on the figures in app designer

Asked by Zhangjun Yu on 28 Mar 2016
Latest activity Commented on by Waleed Sahhary on 5 Nov 2018
I cannot find the method for adding an toolbar with function of zoom in/out in the app designer, if it is not been supported now?

  0 Comments

Sign in to comment.

4 Answers

Answer by Chris Portal on 10 Apr 2016
 Accepted Answer

Unfortunately, App Designer does not offer support for adding a toolbar at this time.

  2 Comments

try this workaround pleas: zoom(app.UIAxes,'on')

Sign in to comment.


Answer by Mirek Janda on 16 Apr 2018
Edited by Mirek Janda on 18 Apr 2018

You can try this:

               pan(app.UIAxes,'on');
               zoom(app.UIAxes,'on');

Then create a button to get the zoom 'off' and reset the axis:

                 zoom(app.UIAxes,'off');
                 app.UIAxes.XLimMode = 'auto';
                 app.UIAxes.YLimMode = 'auto';

  3 Comments

good answer. I wonder why they support this but not
zoom(app.UIAxes, 'out')
?
Can you provide an example code in app designer with the callbacks?
Sure. In standard matlab I can do this:
figure
plot(1:10)
drawnow
zoom(gca,'on') %start zoom mode
keyboard
%click, zooms in
zoom(gca,'out') %zooms out
keyboard
%check that figure is zoomed out
zoom(gca,'off') %exit zoom mode
If I have an axes in appdesigner, I can do
zoom(app.UIAxes, 'on')
%now clicking/scrolling in the figure will zoom in
zoom(app.UIAxes, 'off')
but not
>> zoom(app.UIAxes, 'out')
Error using matlab.ui.control.UIAxes/togglemode
Unknown action character vector.

Sign in to comment.


Answer by Blanca Larraga on 28 May 2018

Is there any option to just apply the zoom option to one of the two axis? Thank you very much in advance.
Best regards, Blanca

  0 Comments

Sign in to comment.


Answer by Luciano Junior on 9 Jan 2018

Try to build your on zoom ;) Once your figure is ploted, add an edit field (here you should insert the specific area in your figure to where you want to zoom) after add a slider to control the zoom (the slider values should control your Xlim) add a callback to the slider in order to plot the figure again (use the same code you used to plot the figure but now use the edit field and the slider values to control your XLim) everytime you change the slider value your figure will be updated.
Good luck!

  0 Comments

Sign in to comment.