2017-06-18 29 views
1

凡例のタイトルはかなり重複しているようですが、matplotlibを使用するのは可能でしょうか?私はLABEL1上記伝説のタイトルを望むPython - 凡例matplotlibのタイトル

import matplotlib.patches as mpatches 
import matplotlib.pyplot as plt 

one = mpatches.Patch(facecolor='#f3f300', label='label1', linewidth = 0.5, edgecolor = 'black') 
two = mpatches.Patch(facecolor='#ff9700', label = 'label2', linewidth = 0.5, edgecolor = 'black') 
three = mpatches.Patch(facecolor='#ff0000', label = 'label3', linewidth = 0.5, edgecolor = 'black') 

legend = plt.legend(handles=[one, two, three], loc = 4, fontsize = 'small', fancybox = True) 

frame = legend.get_frame() #sets up for color, edge, and transparency 
frame.set_facecolor('#b4aeae') #color of legend 
frame.set_edgecolor('black') #edge color of legend 
frame.set_alpha(1) #deals with transparency 
plt.show() 

は、ここで私が持っているコードのスニペットです。参考のために、これが出力される。

Showing legend
+0

例1にタイトルパラメータを追加タイトルを有するhttps://matplotlib.org/examples/pylab_examples/legend_demo3.html –

+1

興味のないところでは、何が原因でこの質問をしたのか、それを書くことに努力したり、Googleの代わりに[matplotlib legend title](http://www.google。 de/search?q = title + legend + matplotlib)、またはドキュメントを見ていますか? – ImportanceOfBeingErnest

答えて

2

はちょうどこのライン

legend = plt.legend(handles=[one, two, three], title="title", loc=4, fontsize='small', fancybox=True) 
関連する問題