I want to change the head of an arrow in an annotation (matplotlib
), but it doesn't work when used together with other properties, like shrink
. It seems to change the type of object created, by looking at the parameters set.
Example
The following code shows two types of annotation arrows.
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
I tried to set the arrow type together with the other properties in the first annotation like this:
ax.annotate( 'other\nmax', xy=(np.pi*5/2, 1), xytext=(7,1.5), ha='center', \
arrowprops={'arrowstyle':'->', 'shrink':0.05})
However, that line throws an error:
AttributeError: Unknown property shrink
Why does it not work?
How do I change the arrow head style of an annotation?
I am using:
python: 3.4.3 + numpy: 1.11.0 + matplotlib: 1.5.1