MATLAB: Is MATLAB not clipping plots

3dboxclippingclippingstyleMATLABopenglpeaksplotrendererinfosoftwaresurfzlim

I am trying to create a "surf" plot, and clip it using "zlim" command. However, it is not clipping the plot.
I execute the following code in MATLAB:
>> figure
>> surf(peaks)
>> zlim([-4 4])
And it creates the following figure which is not clipping the peaks:
I then execute the following code to see whether clipping is on and to see what clipping style it is set at:
>> ax = gca
>> ax.Clipping
>> ax.ClippingStyle
And I see that "ax.Clipping" is "on" and "ax.ClippingStyle" is set to "3dBox".
For reference, the above code should produce the following plot:
And if clipping is disabled using the below code, it will give the following plot:
%%Disable clipping
ax.Clipping = 'off';
Why is clipping not working on the plot? How can I solve this graphical issue?

Best Answer

Contact Technical Support Please contact Technical Support and provide them with information about your system from the following MATLAB commands.

In MATLAB R2019a and newer:

>> a = axes;
>> info = rendererinfo(a);
>> info
>> info.Details

In MATLAB R2018b and older:

>> opengl info

Possible workaround: Use software OpenGL A possible workaround is to try switching to software OpenGL by executing the following command from the MATLAB Command Window:

>> opengl software

Possible solution: Update the graphics driver This may be likely due to the graphics driver issue. Updating the graphics drivers for your card may solve the issue.