我有一个由蓝色表面组成的图(通过绘制plot_surface
)和一个红色球体(通过绘制scatter
)。曲面的 zorder 设置为 0,球体的 zorder 设置为 1(尽管不设置任何 zorder 值会产生相同的结果)。
You can see that the red sphere is to the left of the surface:
当我旋转绘图时,您可以看到红色球体开始消失在蓝色表面后面即使它就在它的前面:
Until the red sphere completely disappears:
What is strange is that for certain angles/views the red sphere re-appears and is visible again, such as this one:
这里发生了什么?我已经阅读了其他一些与绘图/zorder 相关的问题,但我还没有看到这种类型的行为,即一个对象明显位于另一个对象的后面/前面,并且在大多数视角下都无法正确显示。
如果我使蓝色表面透明,当红色球体在下面的图中消失时,您可以看到表面后面的红色球体(因此绘图库实际上认为它位于表面后面)。
从 Matplotlib 3.5.0 开始,axis3d 有一个设置可以解决这个问题。这个设置被称为计算的 z 顺序.
Example:
ax = plt.axes(projection='3d',computed_zorder=False)
ax.plot_surface(X, Y, Z,zorder=1)
ax.plot_surface(U, V, W,zorder=2)
最高的元素zorder将显示在顶部。
一些默认的zorder列出了值here https://matplotlib.org/stable/gallery/misc/zorder_demo.html:
Artist |
zorder |
Images (AxesImage, FigureImage, BboxImage) |
0 |
Patch, PatchCollection |
1 |
Line2D, LineCollection (including minor ticks, grid lines) |
2 |
Major ticks |
2.01 |
Text (including axes labels and titles) |
3 |
Legend |
5 |
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)