You can call legend as follows:
plt.legend(loc=0) and it will place the legend where it obscures as little as possible. _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users |
Is this the same as loc='best'?
I actually need to make extra space for the legend. I guess this can only be done manually? On Tue, Feb 16, 2021 at 12:13 PM [hidden email] <[hidden email]> wrote: > > You can call legend as follows: > > plt.legend(loc=0) > > and it will place the legend where it obscures as little as possible. > _______________________________________________ > Matplotlib-users mailing list > [hidden email] > https://mail.python.org/mailman/listinfo/matplotlib-users -- Those who don't understand recursion are doomed to repeat it _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users |
You can use the "loc" argument in combination with "bbox_to_anchor".
Not sure if you call this "manual" or "automatic" but the width of
the legend is adjusted automatically and it can be placed outside
the axes:
plt.figure() plt.plot([1,3,2], label='first') plt.plot([2,1,5], label='second') plt.legend(loc='upper left', bbox_to_anchor=(1,1)) ![]() plt.figure() plt.plot([1,3,2], label='first') plt.plot([2,1,5], label='a very wide legend') plt.legend(loc='upper left', bbox_to_anchor=(1,1)) ![]() Regards, Johann On 16/02/2021 19:56, Neal Becker wrote:
Is this the same as loc='best'? I actually need to make extra space for the legend. I guess this can only be done manually? On Tue, Feb 16, 2021 at 12:13 PM [hidden email] [hidden email] wrote:You can call legend as follows: plt.legend(loc=0) and it will place the legend where it obscures as little as possible. _______________________________________________ Matplotlib-users mailing list [hidden email] https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fmatplotlib-users&data=04%7C01%7C%7C3e608a9c59244760240a08d8d2a4530f%7Ca6fa3b030a3c42588433a120dffcd348%7C0%7C0%7C637490950547351116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=a1T%2Bs3qJVGwEEYT1jNv9THkj2Jj8nQzUT0VQv%2BHidxU%3D&reserved=0-- Those who don't understand recursion are doomed to repeat it _______________________________________________ Matplotlib-users mailing list [hidden email] https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fmatplotlib-users&data=04%7C01%7C%7C3e608a9c59244760240a08d8d2a4530f%7Ca6fa3b030a3c42588433a120dffcd348%7C0%7C0%7C637490950547351116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=a1T%2Bs3qJVGwEEYT1jNv9THkj2Jj8nQzUT0VQv%2BHidxU%3D&reserved=0 The integrity and confidentiality of this e-mail is governed by these terms / Die integriteit en vertroulikheid van hierdie e-pos word deur die volgende bepalings gereël. http://www.sun.ac.za/emaildisclaimer _______________________________________________ Matplotlib-users mailing list [hidden email] https://mail.python.org/mailman/listinfo/matplotlib-users |
Free forum by Nabble | Edit this page |