← 返回章节索引

CHAPTER 03 · 作品已接入

注释文本

用 annotate() 与 text() 在图表中添加说明文字。

10075502500246810 y = 0.8x + 12local dip ↘ Annotation Text X axis Y axis
import matplotlib.pyplot as plt

plt.plot(x, y)
plt.text(6, 70, 'y = 0.8x + 12')
plt.annotate('local dip', xy=(4, 23),
arrowprops=dict(arrowstyle='->'))
plt.show()
坐标轴标签标题与图例网格参考线 / 区域注释文本