[Matplotlib-users] fig.legend method and axes.legend method behaves differently?
Eric Firing
efiring at hawaii.edu
Fri Jan 12 02:31:11 EST 2018
It looks like the bbox_to_anchor argument is causing the problem. If
you try this:
legend = fig.legend(handles, labels,
loc='upper center',
ncol=2, frameon=False,)
plt.savefig('test.jpg', bbox_extra_artists=(legend,),
bbox_inches='tight')
it works, with 'upper center' or 'lower center'.
Eric
On 2018/01/07 6:16 AM, Henry east wrote:
> Hi,
> I tried to make a plot with two subplots but only one legend since the
> two subplots express the same set of information.
> I put the legend outside of the two subplots for better interpretation.
> I have found that by using |fig.legend| instead of
> the |ax.legend| method. In the saved plot, the legend box are just cut off.
>
> I tried to fix this by using |bbox_extra_artists| argument in the
> |savefig| method, following the instruction
> here
> <https://stackoverflow.com/questions/10101700/moving-matplotlib-legend-outside-of-the-axis-makes-it-cutoff-by-the-figure-box>.
> But it does not work. The following code illustrate the problem,
More information about the Matplotlib-users
mailing list