python

【python matplotlib】グラフのアノテーションの線(矢印)が出ない

問題点

matplotlibのグラフにアノテーションを付ける際に、annotateを使いますが、その際、注釈と点は出るが、注釈と点をつなげる線(矢印)が表示されない。

 

「世界で18万人が受講」実践 PythonデータサイエンスをUdemyで勉強中の方に役立つ情報です。

【python matplotlib】グラフのアノテーションの線(矢印)が出ない

アノテーションの線を出す方法

Before

 

gens
gens
annotateの引数:arrowpropsの設定を追加しました。

 

変更前
arrowprops = dict(arrowstyle=’-‘, connectionstyle= ‘arc3’)

変更後
arrowprops = dict(arrowstyle=’-‘, connectionstyle= ‘arc3’,facecolor=’C0′,edgecolor=’C0′)

 

facecolorとedgecolorを追加しました。

 

AFTER

こちらのサイトを参考にしました。