擅长:python、mysql、java
<p><strong>对于Matplotlib 1.4+,下面由@fraxel提供的答案是最佳解决方案:使用参数<code>depthshade=False</code>调用<code>ax.scatter</code>。</strong></p>
<p>没有任何参数可以控制这一点。这里有一些破解方法。</p>
<p>禁用<code>set_edgecolors</code>和<code>set_facecolors</code>方法,以便mplot3d无法更新颜色的alpha部分:</p>
<pre><code>from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection='3d')
x = np.random.sample(20)
y = np.random.sample(20)
z = np.random.sample(20)
s = ax.scatter(x, y, z, c="r")
s.set_edgecolors = s.set_facecolors = lambda *args:None
ax.legend()
ax.set_xlim3d(0, 1)
ax.set_ylim3d(0, 1)
ax.set_zlim3d(0, 1)
plt.show()
</code></pre>
<p><img src="https://i.stack.imgur.com/R336B.png" alt="enter image description here"/></p>
<p>如果以后要调用<code>set_edgecolors</code>和<code>set_facecolors</code>方法,可以在禁用这两个方法之前备份它们:</p>
^{pr2}$