Date: Feb 12, 2013 11:21 PM
Author: matt dash
Subject: Re: Surface Clipping

"Dmytro" wrote in message <kfdpbn$kej$1@newscl01ah.mathworks.com>...
> Hello,
>
> Does anybody know, how to really clip/truncate surface plot to axes limits? I.e. make it not displaying any data out of the limits? One of the possible ways is of course replace data out of limits with NaNs, but this makes saw-tooth pattern near the edges, which does not look ok.
>
> This question have already been asked long ago (http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/294827) by other user, but no answer have been given.
>
> In MatLab documentation in Surface Properties there is a property Clipping, and it says 'Clipping to axes rectangle. When Clipping is on, MATLAB does not display any portion of the surface that is outside the axes rectangle.'. But it does not work (MatLab 7.12.0 (R2011a))!
>
> At the same time, I also noticed that in the 3rd Figure of http://www.mathworks.co.uk/help/curvefit/exploring-and-customizing-plots.html (right top corner of it) surface plots are indeed very well clipped to axes! How??? No explanation is given.
>
> So can anybody clarify this issue?
>
> Thanks in advance,
>
> Dima


Unfortunately, the clipping property does exactly what it says it does... it clips to the "axes rectangle", which is the rectangle on your screen that encloses the entire 3d axes. (i.e. the portion of the figure denoted by the axes 'position' property). It does NOT clip to the 3d axes themselves. That would make too much sense. I think your only option is to make an opaque plane using the patch function and place it in your axes where you want the clipping to occur. You could probably write a little function to do this automatically whenever you need it...