MATLAB: Is part of the graph cut off in MATLAB R2014b

MATLABr2014bgraphics

I have a 3D surface that I am trying to plot in MATLAB R2014b. I noticed that a part of the surface is clipped off after I specified the limits for the z axis. This did not happen in MATLAB R2014a. Why is this so?

Best Answer

Starting in R2014b, graphics objects do not extend beyond the axes boundaries. Objects are clipped to the six sides of the axes box defined by the axes limits. For example, MATLAB® does not display the peaks of this surface that extend beyond the specified z-limits.
surf(peaks);
zlim([-3,4.5]);
In R2014a and earlier, MATLAB uses a different technique to clip objects. Instead of clipping to the axes limits, MATLAB clips to the smallest 2-D rectangle that encloses the axes. For example, in previous releases, the same surface plot extends beyond the specified z-limits. The red rectangle indicates the boundaries used for clipping.
surf(peaks);
zlim([-3,4.5]);
The axes and individual objects in the axes have a 'Clipping' property that controls the clipping behavior. By default, this property is set to 'on'. To disable clipping, set the 'Clipping' property to 'off'.
If the 'Clipping' property for the axes is 'on', then each individual object in the axes controls its own clipping behavior. To disable clipping for all objects in the axes, set the 'Clipping' property for the axes to 'off'.
For example, disable the clipping for all objects in the axes by setting the Clipping property of the axes to 'off'.
surf(peaks);
zlim([-3,4.5]);
ax = gca;
ax.Clipping = 'off';
The new 'ClippingStyle' axes property introduced in R2014b controls the technique used to clip objects. Set this property to one of these values:
·         '3dbox' — Clip objects to the six sides of the axes box defined by the axes limits. This is the default value.
·         'rectangle' — Clip objects to the smallest 2-D rectangle that encloses the axes in any given view.
To get the same style of clipping used in R2014a and earlier, set the ClippingStyle to 'rectangle'.
surf(peaks)
zlim([-3,4.5]);
ax = gca;
ax.ClippingStyle = 'rectangle';
<<http://www.mathworks.com/matlabcentral/answers/uploaded_files/19112/1cc4c5615fe2b461c6063e9d548acd98.png>>