【Python学习】matplotlib添加文字标注

import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 6)
y = x * x
plt.plot(x, y, marker='o')
for xy in zip(x, y):
    plt.annotate("(%s,%s)" % xy, xy=xy, xytext=(-20, 10), textcoords='offset points')
plt.show()

【Python学习】matplotlib添加文字标注_第1张图片

你可能感兴趣的:(python学习,python,matplotlib)