我想更改注释中的箭头头(matplotlib
),但与其他属性一起使用时不起作用,例如shrink
。通过查看参数集,它似乎改变了创建的对象的类型。
Example
以下代码显示了两种类型的注释箭头。
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':'->'})
Problem
我尝试将箭头类型与第一个注释中的其他属性一起设置,如下所示:
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
为什么它不起作用?
如何更改注释的箭头样式?
相关问题 https://stackoverflow.com/questions/36148773/how-to-change-the-head-size-of-the-double-head-annotate-in-matplotlib
我在用:
蟒蛇:3.4.3 + numpy:1.11.0 + matplotlib:1.5.1