2015-01-17 177 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