rhino
0
Q:

python matplotlib place legend outside plot

plt.legend(bbox_to_anchor=(1, 1), loc='best') # Try this
# Other locations include [upper right, upper left, lower left, 
# lower right, right, center left, center right, lower center, 
# upper center, and center]
# A full example is a bit long, see source. 
2
import numpy as np
import matplotlib.pyplot as plt

#Define arrays x, y1, y2, y3

fig = plt.figure()
ax = fig.add_axes((0.1,0.4,0.5,0.5))

ax.plot(x1,y1,linestyle='-',label='one')
ax.plot(x1,y2,linestyle='--',label='two')
ax.plot(x1,y3,linestyle='dotted',label='three')

ax.legend(bbox_to_anchor=(1.05,1.0),loc='best')

fig.savefig('Figure1.pdf')
1

New to Communities?

Join the community