This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Why Is Part of the Graph Cut Off?

Graphics Objects No Longer Extend Beyond Axes Boundaries

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]);

Disable Clipping

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'. This table lists the results for different combinations of Clipping property values.

Clipping Property for AxesClipping Property for Individual ObjectResult
'on''on'Individual object is clipped (default)
'on''off'Individual object is not clipped
'off''on'No objects in axes are clipped
'off''off'No objects in axes are clipped

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';

Control Style of Clipping

The new ClippingStyle axes property controls the technique used to clip objects. Set this property to one of these values:

  • '3dbox' — Clips objects to the six sides of the axes box defined by the axes limits. This is the default value.

  • 'rectangle' — Clips objects to the smallest 2-D rectangle that encloses the axes in any given view.

To get the same style of clipping as in R2014a and earlier, set the ClippingStyle to 'rectangle'.

surf(peaks)
zlim([-3,4.5]);
ax = gca;
ax.ClippingStyle = 'rectangle';

See Also