我想要更改注释(matplotlib
)中箭头的头部,但是当与其他属性一起使用时,例如 shrink
,它似乎无法正常工作。通过查看设置的参数,似乎更改了所创建对象的类型。
示例
以下代码显示了两种类型的注释箭头。
import matplotlib.pyplot as plt
import numpy as np
xx = np.linspace(0,8)
yy = np.sin(xx)
fig, ax = plt.subplots(1,1, figsize=(8,5))
ax.plot(xx,yy)
ax.set_ylim([-2,2])
ax.annotate( 'local\nmax', xy=(np.pi/2, 1), xytext=(1,1.5), ha='center', \
arrowprops={'shrink':0.05})
ax.annotate( 'local\nmin', xy=(np.pi*3/2, -1), xytext=(5,0), ha='center', \
arrowprops={'arrowstyle':'->'})
问题
我尝试将箭头类型与第一个注释中的其他属性一起设置,如下所示:
ax.annotate( 'other\nmax', xy=(np.pi*5/2, 1), xytext=(7,1.5), ha='center', \
arrowprops={'arrowstyle':'->', 'shrink':0.05})
然而,这行代码会抛出一个错误:
AttributeError: Unknown property shrink
为什么它不起作用?
如何更改注释的箭头样式?
我正在使用:
python: 3.4.3 + numpy: 1.11.0 + matplotlib: 1.5.1