Matplotlib 3D解决方案,用于打印顺序

时间:2018-10-22 06:35:31

标签: python matplotlib mplot3d

我知道matplotlib 3D对于以正确的顺序绘制多个3D对象(平面,直线,点)不可靠:请参见Matplotlib 3D plot zorder issueHow to draw intersecting planes?。 但是这些问题似乎已经很老了,因此提出了解决方案。因此,我想知道针对以下特定的简单场景是否有一些新的开发,工具,变通方法或硬编码的解决方案:

import mpl_toolkits.mplot3d as a3
import matplotlib.pylab as plt
import numpy as np    

fig = plt.figure()
ax = a3.Axes3D(fig)

# create an orizontal plane
corners = [[0,0,0],[0,5,0],[5,5,0],[5,0,0]]
tri = a3.art3d.Poly3DCollection([corners], alpha=1)
tri.set_color('w')
tri.set_edgecolor('k')
ax.add_collection3d(tri)

# plot a vector
ax.plot([2,2],[2,2],[0,4], c = 'r')

# plot some points
ax.scatter([1,3],[1,3],[1,3], c = 'r')

ax.set_xlim([0, 5.0])
ax.set_ylim([0, 5.0])
ax.set_zlim([0, 2.5]);

plt.show()

In this image you can see the visualization issues: the vector it is not starting from the plane, as it should since his intiali point is (2,2,0)

在此图像中,您可以看到可视化问题:矢量不是从平面开始的,因为它的初始点是(2,2,0)

0 个答案:

没有答案