简体   繁体   English

Matlab 3D Plot(surf)自动填充空白

[英]Matlab 3D Plot (surf) fills in empty gaps automatically

I'm using surf() to plot a portion of a sphere; 我正在使用surf()绘制球体的一部分; basically a shell of a certain shape that is on top of a sphere. 基本上是球形的某种形状的壳。 More specifically, it is the workspace plot of spherical joint with color representing the resolution of the joint at that point. 更具体地说,它是球形接头的工作区图,其颜色表示该点处接头的分辨率。

Anyways, the shape is unique, but surf() automatically fills in gaps that should not be there. 无论如何,形状都是唯一的,但是surf()自动填充不应存在的间隙。 I'm guess it might be the order that it is plotted? 我猜可能是绘制的顺序? Is there any way to prevent Matlab from doing this? 有什么方法可以防止Matlab这样做吗?

I think it is obvious in the pictures what should not be there: 我认为在图片中显而易见什么不应该存在:

第一张图片

在此处输入图片说明

Also, it seems to mess up the color coding as well. 另外,它似乎也弄乱了颜色编码。 The dark blue should be at the bottom edges of the shell; 深蓝色应位于外壳的底部边缘; instead Matlab assigns it to the surface used to fill the gaps. Matlab而是将其分配给用于填充间隙的表面。

The following code achieves what I think you are asking (namely - making part of a surface plot "invisible", which I do by defining a matrix transp of the same dimensions as zz , with alpha values (1=visible, 0=transparent). Of course you will have to change your definition of transp to match the parts of the surface you don't want to see - my simple clipping method is just to show what can be done): 下面的代码实现了我认为的要求(即-使表面图的一部分“不可见”,我可以通过定义与zz尺寸相同的矩阵transp和alpha值(1 =可见,0 =透明)来完成此操作当然,您必须更改transp的定义以匹配您不希望看到的表面部分-我的简单裁剪方法只是显示可以做什么):

[xx yy]=meshgrid(linspace(-1,1,200));
zz = 1./(xx.^2 + yy.^2 + 0.5);
theta = atan2(yy,xx);
r = sqrt(xx.^2 + yy.^2);
transp = double(r < (0.3*cos(6*theta)+0.6));
figure
surf(xx,yy,zz,'edgecolor','none','FaceAlpha', 'interp', 'AlphaData', transp);

This gives the following plot: 这给出了以下图:

在此处输入图片说明

I trust you can figure it out from here. 我相信您可以从这里解决。 If this doesn't work you need to give more information about the data you have - what is the size, how are you plotting it... 如果这不起作用,则需要提供有关所拥有数据的更多信息-大小如何,如何绘制...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM