First conclusion: I gave up passing the spray data as a list and scatter () one by one to solve the problem.
When using the scatter plot drawing method scatter () I usually want to pass the marker position and color coding value in a list.
List xs,ys,zs,When passing vs
ax.scatter(xs, ys, zs, c=vs, norm=norm, s=600, marker='o', alpha=1.0, zdir='z', depthshade=False )
However, for some reason, as soon as I passed the color scheme with c = vs, the hidden surface erasure went crazy. It happens that the marker in the foreground is hidden behind the marker in the back and cannot be seen. (Maybe it depends on the version.)
Action: As a result of trying everything I can think of It was normal when I set "scatter () one marker at a time in the for statement".
Scatter for each one()
ax = fig.add_subplot( 122, projection='3d')
for x,y,z,v in zip(xs,ys,zs,vs):
ax.scatter(x, y, z, c=(v,),norm=norm, s=600, marker='o', alpha=1.0, zdir='z', depthshade=False )
The following is an example:
Erasing comparison
def plot():
def randrange(n, vmin, vmax):
return (vmax - vmin)*np.random.rand(n) + vmin
n = 20
xs = randrange(n, 0, 100)
ys = randrange(n, 0, 100)
zs = randrange(n, 0, 100)
vs = xs
norm = Normalize(vmin=min(vs), vmax=max(vs) )
fig = plt.figure()
ax = fig.add_subplot(121, projection='3d')
ax.scatter(xs, ys, zs, c=vs, norm=norm, s=600, marker='o', alpha=1.0, zdir='z', depthshade=False )
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax = fig.add_subplot( 122, projection='3d')
for x,y,z,v in zip(xs,ys,zs,vs):
ax.scatter(x, y, z, c=(v,),norm=norm, s=600, marker='o', alpha=1.0, zdir='z', depthshade=False )
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
Python3.8 execution result ↓
↑ When the left figure is passed as a list, and the right figure is passed one by one. (I intended to draw in a direction that is easy to distinguish)
The figure on the right is normal.
important point:
The behavior of scatter () and scatter3d () is probably the same.
We have not confirmed the official documentation of matoplotlib. In the first place, the usage of the premise may be wrong. I don't know.
Recommended Posts