Description
I understand that 3d plotting is as yet a bit hacky, but from what little I understand of the code for Path3DCollection
(or is it Patch3DCollection
as the docstring for scatter says?), it feels like this should be fixable (patches aren't intersecting each other here).
I'm using Matplotlib v1.5.0. The zorder of markers plotted by 3d scatter goes wrong in certain views.
Here's a minimal example:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
x = np.array([-1, 0, 1])
y = np.array([0, 0, 0])
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
patches = ax.scatter(x, y, y, s=2500, c=x)
plt.show()
I've made the marker sizes really huge to illustrate the point clearly - in the initial view, the overlap is correct (in this example), but on rotation, it goes wrong:
It's not fully clear because of the depthshading, but red is on top of green, which is on top of blue.
It definitely looks like some zorder information is present - depthshade is using it correctly - but it's not being used to update the drawing order correctly.
This problem gets severely exacerbated as the number of scatter points increases. To demonstrate, execution of this gist produces the following ugly result:
The sphere ought to be mostly red (it's the top view of a spherical grid with color=z-coordinate), instead it's mostly blue because of poor ordering. Rotating it will make it seem like there are holes in the sphere at different places because of incorrect overlap in some strange patterns.