pl.scatter(X[:,0], X[:,1], c = labels)
for item in labels:
#dummy plot just to create the legend
pl.scatter([], [], c = item, label = item)
#loc = 0 is for the best position of the legend
#scatterpoints = 1 will only show one point in the legend instead of multiple points
plt.legend(loc = 0, scatterpoints = 1)
pl.show()
只需标记每个绘图并像您所做的那样调用legend()。)
可以使用所需图例创建虚拟散点图,如下所示:
相关问题 更多 >
编程相关推荐