我试图用Matplotlib在python2.7中注释散点图。以下是绘图代码:import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.DataFrame(np.random.rand(5,3), columns=list('ABC'))
df.insert(0,'Annotation_Text',['ABC','DEF','GHI','JKL','mnop'])
q = 2
pqr = 1
# Scatter Plot:
x = df['A']
y = df.iloc[:,q]
plt.scatter(x, y, marker='o', label = df.columns.tolist()[q])
# Plot annotation:
plt.annotate(df.iloc[pqr,0]+', (%.2f, %.2f)' % (x.ix[pqr],y.ix[pqr]), xy=(x.ix[pqr], y.ix[pqr]), xycoords='data', xytext = (x.ix[pqr], y.ix[pqr]), textcoords='offset points', arrowprops=dict(arrowstyle='-|>'))
# Axes title/legend:
plt.xlabel('xlabel', fontsize=18)
plt.y