views:

213

answers:

1

I added the legend this way:

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')

but the legend appears inside the plot.

How can I tell matplotlib to put it to the right of the plot and at the right?

+2  A: 

did you try:

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

'right' shows the legend at the right of the axes

as for the second question (help for a command) you could look at the matplotlib demos (for example http://matplotlib.sourceforge.net/examples/api/legend_demo.html and API (for example, http://matplotlib.sourceforge.net/api/figure_api.html#module-matplotlib.figure)

joaquin
gracias joaquín
Werner