2013-06-05 51 views
0

我想在python的matplotib圖中的圖例中添加一些文本。我正在考慮創建一個空的句柄,有沒有辦法做到這一點?已經嘗試使用類似的東西:matplotlib空的圖例句柄

ax.legend([handle1,handle2,None],[label1,label2,labelEmpty]) 

但傳說不接受無關鍵字。 (我得到錯誤$ Legend不支持None,請使用代理藝術家代替$)

如果這不可能有其他想法?

我想在具有類似:

___________________________ 
| handle1 - label1  | 
| handle2 - label2  | 
|  labelEmpty   | 
!___________________________! 

的感謝!

回答

3

空條目和標題:

ax = gca() 
h1, h2 = ax.plot(range(5), range(5), range(5), arange(5)**2) 

r = matplotlib.patches.Rectangle((0,0), 1, 1, fill=False, edgecolor='none', 
           visible=False) 
ax.legend([h1, h2, r], ['a', 'b', 'c'], loc=0, title='test') 
plt.draw() 

enter image description here

+0

完美,正是我想要的,謝謝! :) – jorgehumberto