我正在绘制分为三个不同集群的三维散点数据:一个是红色,一个是绿色,一个是蓝色。
我遇到的问题是,当集群随相机旋转时,查看器不会按照您通常期望的空间顺序显示集群(即:最近的集群应该遮挡距离最远的集群相机)。相反,我看到堆叠优先级由颜色决定(在本例中为 R->G->B),红色优先于绿色,绿色优先于蓝色。
在下面的链接中,红色的簇应该隐藏在绿色的后面而不是在它上面。 http://imgur.com/TdjW9aI
那么,是什么控制了散点数据的堆叠顺序(排列),我该如何更改它,以便按照靠近相机的顺序给出显示优先级?
from pylab import *
from numpy import *
from mpl_toolkits.mplot3d import axes3d
fig = figure()
ax = fig.gca(projection='3d')
# plot points in 3D
class1 = 0.5 * random.standard_normal((200,3))
ax.plot(class1[:,0],class1[:,1],class1[:,2],'o')
class2 = 0.7 * random.standard_normal((700,3)) + array([5,4,0])
ax.plot(class2[:,0],class2[:,1],class2[:,2],'o')
class3 = 0.3 * random.standard_normal((200,3)) + array([2,3,2])
ax.plot(class3[:,0],class3[:,1],class3[:,2],'o')
ax.set_xlabel('X-axis')
ax.set_ylabel('Y-axis')
ax.set_zlabel('Z-axis')
plt.show()
最佳答案
参见 these limitations用于 3D 绘图的 matplotlib。
如果您需要动态良好的 View (即移动绘图的能力),我认为没有解决方案。如果不这样做,您可以将 zorder
关键字传递给所有绘图调用并获得您想要的结果。
关于matplotlib - mplot3d彩色散点数据堆叠显示优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26847994/