2016-05-18 17 views
1

これはバグか間違っているのか分かりません。私の目標は、伝説にハッチを表示することですが、それは動作しません。私はそのために使用するコードはMatplotlibは凡例にパッチのハッチを表示しません

import matplotlib.patches as mpatches 
... 
def plot_legend(ax): 
    ep = mpatches.Patch(color=[1.0, 0.5, 1.0, 1], hatch='/', 
     label=r'$\pi_e\ free$') 
    cp = mpatches.Patch(color=[1.0, 1.0, 1.0, 1], label='$\pi_e = exp(-60)$') 
    #ax.legend(handles=[ep, cp], bbox_to_anchor=(1.05, 1), 
    # loc=2, borderaxespad=0.) 

    pyl.legend(handles=[ep, cp], 
     loc=1) 

    return 

結果は以下の通りですされています。私が使用しているmatplotlibのの

The weird color in the legend is to show that is working.

をバージョンは、Macコンピュータでは1.5.1です。

答えて

1

mpatches.Patchcolorキーワードは、おそらくedgecolorfacecolorの両方に適用されています。あなたのハッチはそこにあるかもしれませんが、同じ色のために見えません。明示的facecolorを指定

はあなたの問題を解決する必要があります。

ep = mpatches.Patch(edgecolor=[1.0, 0.5, 1.0, 1], edgecolor=[0.5, 1.0, 1.0, 1], hatch='/', label=r'$\pi_e\ free$')

はその助けをしていますか?

+0

ありがとう、それは仕事をしました。それはまだ奇妙な行動であると思います。 – eaponte

関連する問題