Mplot3d color display priority of color scattering data

I am plotting 3D scatter data grouped into three different clusters: one red, one green, and one blue one blue.

The problem I ran into is that when the clusters rotate in a queue with the camera, the viewer does not display the clusters in the spatial order you would normally expect (i.e. the closest cluster should overlap the ones farthest from the camera). Instead, I see that stacking priority is determined by color (in this case R-> G-> B), with red taking precedence over green and green over blue.

In the next link, the red cluster should be hidden behind the green one, not above it. http://imgur.com/TdjW9aI

So what controls the stacking (stacking) order of the scatter data, and how do you change it so that the display priority is set in order of proximity to the camera?

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()

      

+3


source to share


1 answer


See these matplotlib limitations for 3D plotting.



I don't think there is a solution if you want a dynamically good view (i.e. the ability to move the plot). If you don't, you can pass the keyword zorder

across all call records and achieve the result you intend.

+1


source







All Articles