当我有 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()
它非常适合这样的颜色:
但是我不能用不同的标记做同样的事情,它不能识别标记列表。
如何为每个集群设置不同的标记
(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)
关于python - 条件标记 matplotlib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41099887/