Python matplotlib scatter - different markers in one scatter

后端 未结 2 1822
时光取名叫无心
时光取名叫无心 2020-12-06 14:22

I want to display some points. Here is my code:

plt.scatter(y[:,0],y[:,1],c=col)
plt.show()

And as col I have:



        
2条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 14:57

    You can use one scatter plot per marker.

    markers = ["s","o"]
    for i, c in enumerate(np.unique(col)):
        plt.scatter(y[:,0][col==c],y[:,1][col==c],c=col[col==c], marker=markers[i])
    

    For a way to use several markers in a single scatter plot, see this answer.

提交回复
热议问题