绘制 3D 曲面时消除伪影/网格线

发布于 2024-11-14 16:01:34 字数 585 浏览 3 评论 0原文

使用 mpl_toolkits.mplot3d.Axes3D.plot_surface() 绘制曲面时,出现的线条似乎遵循所绘制曲面的曲线。例如:

X, Y = numpy.meshgrid(numpy.arange(some_range), numpy.arange(some_other_range))
Z1, Z2 = numpy.array(getRate()) 
#getRate is a function that returns an array of shape (len(some_range), len(some_other_range)  

fig = pyplot.figure()
ax = mplot3d.Axes3D(fig)

ax.plot_surface(X, Y, Z1, color='w', alpha=0.2)
ax.plot_surface(X, Y, Z2, color='b', alpha=0.2)

pyplot.show()

有没有什么办法可以去掉血腥的东西,让你的表面光滑?我附上了一张图片来说明我的意思。 在此处输入图像描述

When plotting surfaces using mpl_toolkits.mplot3d.Axes3D.plot_surface(), lines appear that seem to follow the curve of the surfaces being plotted. For example:

X, Y = numpy.meshgrid(numpy.arange(some_range), numpy.arange(some_other_range))
Z1, Z2 = numpy.array(getRate()) 
#getRate is a function that returns an array of shape (len(some_range), len(some_other_range)  

fig = pyplot.figure()
ax = mplot3d.Axes3D(fig)

ax.plot_surface(X, Y, Z1, color='w', alpha=0.2)
ax.plot_surface(X, Y, Z2, color='b', alpha=0.2)

pyplot.show()

Is there any way to get rid of the bloody things so you just have a smooth surface? I've attached an image to show what I mean. enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抱猫软卧 2024-11-21 16:01:34

尝试

ax.plot_surface(X, Y, Z1, color='w', alpha=0.2, linewidth=0)
ax.plot_surface(X, Y, Z2, color='b', alpha=0.2, linewidth=0)

不过,如果去掉线条会使部分表面变得难以看到,您可能需要稍微增加 alpha 值。

Try

ax.plot_surface(X, Y, Z1, color='w', alpha=0.2, linewidth=0)
ax.plot_surface(X, Y, Z2, color='b', alpha=0.2, linewidth=0)

You may want to increase your alpha values a bit, though, if taking away the lines makes parts of the surfaces too hard to see.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文