七月
31
matplotlib教程:注释
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-10, 11)
y = x * x
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y)
# xy 元组,表示箭头尖的坐标
# xytext 表示文字的位置
# arrowprops 用于配置箭头的样式
## facecolor 箭头颜色
## headlength headwidth 箭头的长度和箭头的宽度
## width 箭尾的宽度
ax.annotate('this is the bottom', xy=(0, 0), xytext=(0, 20),
arrowprops=dict(facecolor='r', headlength=10, headwidth=10, width=5))
# 设置ax的标题
ax.set_title('annotation example')
plt.show()