matplotlib

matplotlib で、矢印を描く方法

投稿日:

arrowprops のパラメータは次を参考にして設定できる。

https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.FancyArrowPatch.html#matplotlib.patches.FancyArrowPatch

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig, ax = plt.subplots()
ax.axis([-2,2,-2,2])

plt.rcParams['font.family'] = 'Hiragino Sans'

arrowprops=dict(width=5, headwidth=50, headlength=30)
an = ax.annotate('矢印1', xy=(1, 0.5), xytext=(-1, -1), xycoords='data', 
                 textcoords='data', arrowprops=arrowprops)

plt.show()

結果

-matplotlib
-

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

matplotlib で、x,y の軸上の数値を表示する方法

ax の xtics と ytics を使って表示する。 詳細は次のドキュメントを参照。 https://matplotlib.org/stable/gallery/lines_bars_and_ma …

no image

matplotlib で、x軸・y軸の目盛りを反対方向につけたい場合。

デフォルトでは、x軸はグラフの下に、y軸は左側につけられる。 例 import numpy as np from matplotlib import pyplot as plt x = np.lins …

no image

matplotlib で、粗い刻みと細かい刻みの目盛りを表示する方法

set_major_locator で粗い刻みの目盛りを調整する。 set_minor_locator で、細かい刻みの目盛りを調整する。 以下の例で set_major_formatter は、表示 …

no image

matplotlib でグラフ表示ウィンドウの画面上の位置を自由に設定する方法

matplotlib.use(‘TkAgg’) としておき、 get_current_fig_manager().window.wm_geometry(“+20+50”) として、(+20+50)のと …

no image

matplotlib で、軸に垂直・平行な線を書く方法

axhline, axvline を使ってx,y軸に平行な線を描くことができる。 https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot …