2013-06-05 47 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