繁体   English   中英

从图中创建matplotlib图例

[英]Create matplotlib legend out of the figure

我以这种方式添加了图例:

leg = fig.legend((l0,l1,l2,l3,l4,l5,l6), 
    ('0 Cl : r2, slope, origin',
    '1 Cl :'+str(r1b)+' , '+str(m1)+' , '+str(b1),  
    '2 Cl :'+str(r2b)+' , '+str(m2)+' , '+str(b2),  
    '3 Cl :'+str(r3b)+' , '+str(m3)+' , '+str(b3),  
    '4 Cl :'+str(r4b)+' , '+str(m4)+' , '+str(b4),  
    '5 Cl :'+str(r5b)+' , '+str(m5)+' , '+str(b5),  
    '6 Cl :'+str(r6b)+' , '+str(m6)+' , '+str(b6),  
    ),  'upper right')

但图例出现在情节中。

我如何告诉matplotlib将其放在图的右边和右边?

你试过了吗:

fig.legend((plot1,plot2), (lab1,lab2), 'right')

“右”在轴的右侧显示图例

至于第二个问题(命令帮助),则可以查看matplotlib演示(例如http://matplotlib.sourceforge.net/examples/api/legend_demo.html和API(例如http:// matplotlib)。 sourceforge.net/api/figure_api.html#module-matplotlib.figure

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM