Put the legend to the right of the axis, outside the axes. Also grab the legend object. bbox_to_anchor determines where relative to the axis object the legend is.
Then when you save, tell savefig that it needs to not freak out about the legend:
fig.savefig(fig_title, bbox_extra_artists=(lgd,), bbox_inches='tight')
No comments:
Post a Comment