2016-12-12 33 views
1

我繪製高斯混合的結果時,我有3類型的點是由預測確定。我預測每個羣集都有不同的顏色,現在我想要有一個不同的標記而不是顏色。有條件的標記matplotlib

colors=['pink' if i==0 else 'skyblue' if i==1 else 'lightgreen' for i in resultGM] 
markers=['c' if i==0 else 'o' if i==1 else 'D' for i in resultGM] 
ax=plt.gca() 
ax.scatter(datas[:,0], datas[:,1], alpha=0.8, c=colors,marker=markers) 
plt.title("Calling "+name_snp) 
plt.xlabel('LogRatio') 
plt.ylabel('Strength') 
plt.show() 

它完美的顏色是這樣的: enter image description here

但我不能做同樣的事情用不同的標記,它不能識別的標記列表。

我該如何爲每個簇(0,1,2)使用不同的標記,就像我使用顏色一樣?

+1

你必須通過他們循環。見這裏http://stackoverflow.com/questions/41078331/matplotlib-read-marker-direction-from-a-file/41078504#41078504 –

回答

2

變化與它plt.scatter行至這個代替:

for x, y, c, m in zip(datas[:,0], datas[:,1], colors, markers) 
    ax.scatter(x, y, alpha=0.8, c=c,marker=m)