2015-01-17 180 views
2

我一直在努力寻找如何在matplotlib中制作三维散点图,只有标记edgecolor和没有标记facecolor。像空心标记一样,像matlab一样。Matplotlib 3D scatter plot no facecolor

解释图片: http://i.stack.imgur.com/LnnOa.jpg

到现在为止,所有的我已经能够做的就是这样的事情: http://ceng.mugla.edu.tr/sharedoc/python-matplotlib-doc-1.0.1/html/_images/scatter3d_demo.png

这是很不理想的基础上,我有想象的样本数。

有没有人设法做到这一点?

回答

0

您可以设置edgecolorfacecolor分开,就像这样:

enter image description here

import numpy as np 
from mpl_toolkits.mplot3d import Axes3D 
import matplotlib.pyplot as plt 

def randrange(n, vmin, vmax): 
    return (vmax-vmin)*np.random.rand(n) + vmin 

fig = plt.figure() 
ax = fig.add_subplot(111, projection='3d') 
n = 100 
for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]: 
    xs = randrange(n, 23, 32) 
    ys = randrange(n, 0, 100) 
    zs = randrange(n, zl, zh) 
    ax.scatter(xs, ys, zs, facecolor=(0,0,0,0), s=100, marker=m, edgecolor=c) 

ax.set_xlabel('X Label') 
ax.set_ylabel('Y Label') 
ax.set_zlabel('Z Label') 

plt.show() 

有几种方法来设置脸上变色透明,看到here

+0

非常感谢。我的错误是使用ax.plot方法,所以它没有设置edgecolor和facecolor的选项。向前到更漂亮的情节。 – Fotis