MATLAB Answers

Change Default Behavior of the Zoom

73 views (last 30 days)
Anael on 10 Oct 2016
Commented: Josh on 19 Jun 2019
It looks like in R2016b the default zoom action is to change the axis limits, which results in "cropping" the 3D objects while maintaining the axes fixed.
I find the old behavior better for me. I can change it for each figure with right click>Camera Pan and Zoom, but I would like to change the default setting permanently. What is the value to edit?
Thank you.


Hans Martin Kjer
Hans Martin Kjer on 11 Oct 2016
Recently noted the same thing. The zoom behavior in 3D plots seems to have been changed indeed.
A quick fix to your problem might be to turn clipping off, i.e.:
set(gca, 'Clipping', 'off')
I'm not sure it is possible to get the old behavior back (where zoom in 3D seemed to work by in- or decreasing the size of the entire plot within the figure window. You can play around the 'Position' property of the axes - set(gca,'Position',[left bottom width height]) - but it is not immediately like the old zoom).
Perhaps someone else can elaborate?
Anael on 6 Mar 2017
This is not what i wanted but it's a cool feature to keep the context around what i'm zooming on!

Sign in to comment.

Accepted Answer

Anael on 6 Mar 2017
It turns out there is no 3DPanAndZoomStyle property to the Axes objects so I couldn't set a Root default behavior. I ended up adding the line below after each 3D plot call.
This function calls the folowing:,hAx,ver3d); which goes to deep for me...
Below are the notes on the version history:
3-D Pan and Zoom: Explore data with improved pan and zoom behavior for axes in a 3-D view For axes in a 3-D view, panning and zooming now shift the view of the data by modifying the axis limits, instead of moving the entire axes. The axes box stays in the same location within the figure. Previously, panning and zooming modified camera properties, which moved the entire axes around within the figure. Compatibility Considerations If you have an axes in a 3-D view, then the behavior of pan and zoom is different. For the old behavior, use one of these options: Use the context menus when in pan or zoom mode. For example, when you are in zoom mode, right-click over the axes and select 3D Options > Camera Pan and Zoom. Use the setAxes3DPanAndZoomStyle function to specify the behavior, for example: ax = gca; z = zoom; setAxes3DPanAndZoomStyle(z,ax,'camera') Use the camera toolbar. To view the camera toolbar, select View > Camera Toolbar from the figure menu.


Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 11 Oct 2016
You prefer the behavior specified by the 'rectangle' value for the ClippingStyle axes property? You can change the default value for that property on groot using the instructions on this documentation page.


Show 1 older comment
Steven Lord
Steven Lord on 13 Oct 2016
See the second link I posted for how to set that property default value using groot. You need to set default values at least one level higher in the hierarchy, so you can set an axes default at the figure or groot levels. Setting it on a figure will affect any new axes created in that figure; setting it on groot will affect any new axes created in that session of MATLAB. Existing axes will be unaffected.
If you want this to persist from one MATLAB session to the next, put it in your startup.m file.
Matt J
Matt J on 7 Jan 2017
I'm wrestling with the same issue. Was there any conclusion to this? "Axes3DPanAndZoomStyle" does not appear to be the name of a groot property that you can set, so it is not clear to me how Steve's advice applies.
Josh on 19 Jun 2019
Matt J, I am also working on this..did you figure it out?

Sign in to comment.

Sign in to answer this question.