实现二维平面上散点的绘制,并可以给每个散点标记序号或者名称:
import numpy as np
import matplotlib.pyplot as plt
x=[2.3,4.5,3,7,6.5,4,5.3]
y=[5,4,7,5,5.3,5.5,6.2]
n=np.arange(7)
fig,ax=plt.subplots()
ax.scatter(x,y,c='r')
for i,txt in enumerate(n):
ax.annotate(txt,(x[i],y[i]))