How to change arrow style in matplotlib annotate?

I want to change the arrow heading in the annotation ( matplotlib), but it does not work when used with other properties, for example shrink. It seems that he changed the type of the created object by looking at a set of parameters.


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':'->'})

enter image description here


Problem

I tried to set the type of arrow along with other properties in the first annotation, for example:

ax.annotate( 'other\nmax', xy=(np.pi*5/2, 1), xytext=(7,1.5), ha='center', \
            arrowprops={'arrowstyle':'->', 'shrink':0.05}) 

However, this line throws an error:

AttributeError: Unknown property shrink

Why is this not working?

How to change annotation arrow heading style?

Question related to us


I use:

python: 3.4.3 + numpy: 1.11.0 + matplotlib: 1.5.1

+4
source share
1 answer

matplotlib documentation" , FancyArrowPatch . , YAArrow.

, shrink YAArrow, FancyArrowPatch.

+1

All Articles