Ely*_*ire 5 python matplotlib markers
当我有 3 种类型的点由预测确定时,我绘制高斯混合的结果。我对预测的每个簇都有不同的颜色,现在我想要有不同的标记而不是颜色。
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()
Run Code Online (Sandbox Code Playgroud)
它非常适合这样的颜色:
但我不能用不同的标记做同样的事情,它不能识别标记列表。
我怎样才能(0,1,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)
Run Code Online (Sandbox Code Playgroud)