matplotlib 在数据上添加标注

x = np.random.random(10)

y = np.random.random(10)

note = np.arange(1,11)

plt.scatter(x,y,marker = 'o', c = 'r')
plt.title('在数据上添加标注',fontproperties='Microsoft YaHei')
for i in range(10):
	plt.annotate(note[i],xy = (x[i],y[i]),xytext = (x[i]+0.01,y[i]+0.01))
plt.show()

  

 

posted @ 2021-12-11 21:57  华小电  阅读(288)  评论(0编辑  收藏  举报