2016-07-31 7 views
4

注釈(matplotlib)の矢印の頭を変更したいが、shrinkのような他のプロパティと共に使用すると機能しない。パラメータセットを調べることで、作成されるオブジェクトのタイプが変わるようです。matplotlib注釈の矢印の頭のスタイルを変更するにはどうすればよいですか?


次のコード注釈矢印の二つのタイプを示します。

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


通報

Iは、矢印が、このような最初の注釈の他の特性と共に入力設定しようとした:

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 

なぜそれが機能しないのですか?

アノテーションの矢印の頭のスタイルを変更するにはどうすればよいですか?

Related question


私が使用しています:

のpython:3.4.3 + numpyの:1.11.0 + matplotlibの:1.5.1

答えて

1

matplotlib documentationから、「辞書場合FantArrowPatchインスタンスが指定された辞書で作成され、描画されます。それ以外の場合は、YAArrowパッチインスタンスが作成され、描画されます。

同じリンクに表示されているように、shrinkYAArrowの有効なキーですが、FancyArrowPatchでは有効ではありません。

関連する問題