How to clip surface plot to axes limits?

5 ビュー (過去 30 日間)
Dmytro
Dmytro 2013 年 2 月 12 日
回答済み: Vladimir Divic 2014 年 5 月 23 日
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 limits, 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
  3 件のコメント
Dmytro
Dmytro 2013 年 2 月 12 日
Besides, just noticed that it clips 3d surface to 2d axes rectangle as specified by axes position (and 'Clipping' property does not change it). But this is just a kind of additional clipping which will be done in any case. Clipping to axes limits in 3d is completely unclear.
2Fida: What do you mean? And why you post it here???
Jelle Reichert
Jelle Reichert 2013 年 8 月 29 日
He Dmytro!
We are stuck with exactly the same problem. We do not have an idea how to solve it and indeed very strange that Matlab itself shows a perfectly clipped plot in the example. Have you found a solution yet?
Greetings, Jelle and Carlo

サインインしてコメントする。

回答 (3 件)

Sean de Wolski
Sean de Wolski 2013 年 2 月 12 日
This Bug Report may be relevent.
The first step for any obscure graphics behavior should be to cycle through all three renderers.
  1 件のコメント
Dmytro
Dmytro 2013 年 2 月 12 日
I checked it before, situation is the same in all renderers.

サインインしてコメントする。


Nico
Nico 2014 年 5 月 16 日
Hello,
according to this post from 2009, Matlab does not have any clipping functionality for 3-D plots: http://www.mathworks.com/matlabcentral/answers/98023-why-does-clipping-fail-to-work-with-matlab-3-d-plots That's a pity, since the quality of 3D plots (e.g., for scientific publications) would be much better with proper clipping.
I would really appreciate it if Mathworks implemented proper clipping of 3D plots in a future version of Matlab.
Btw: I am still using 2013a, could it be that 3d clipping is already possible with the newest version?
Regards, Nico.

Vladimir Divic
Vladimir Divic 2014 年 5 月 23 日
Only way I found to do it is to clip figure manually.
E.g. plot of uncliped data in range -1 to 1 in both x and y axis is
x = -1:0.01:1;
y = -1:0.01:1;
[X,Y]=meshgrid(x,y);
Z = X.^2-Y.^2;
surf(X,Y,Z,'EdgeColor','none')
To clip data to range from 0 to 1 I use interp2 function.
clpx = 0:0.01:1;
clpy = 0:0.01:1;
[clpX,clpY]=meshgrid(clpx,clpy);
clpZ = interp2(X,Y,Z,clpX,clpY);
surf(clpX,clpY,clpZ,'EdgeColor','none')
I hope this helps,
Greetings, Vlado

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by