What does legend(loc=best) does?

Hello, how does loc=0 (best) affects the placement of the

    > legend? I can't really figure out any influence. There is
    > space (on the upper left) where the legend could be
    > placed without hiding any lines but it's still placed on
    > the upper right.

If what you say is correct, then it is a bug. Please post a complete
example.

JDH

This might be a feature rather than a bug.

The legend auto-placement code is a bit lazy – due to the fact that I
wrote it rather than JDH :slight_smile:

Anyway, it only tries to avoid the points that define a line, rather
than the lines themselves.

Much of the time that works well, but since it only takes two points to
define a line you can end up with the lines crossing the legend. The
good news is that if a line does cross the legend, and you can see a
better position for the legend then it almost surely means that the
line is straight throughout the region where it crosses the legend.

Try using the pan/zoom buttons on your plot to move a point into the
legend area and it should jump out of the way.

Eg: try this little snippet – use your pan/zoom skills to position one
of the dots over the legend :wink:

from pylab import *

plot(range(5), ‘o-’, label=‘oops’)

legend(loc=0)

show()

John

John Hunter wrote:

···

<mailinglists@…606…>Matplotlib-users@lists.sourceforge.net

It is correct.

But the John Gill gave me a explanation of this behavior which is correct for
my case. It is not a bug, just a lazy implementation of the feature and he is
aware of that.

Florian

···

Am Dienstag, 17. Mai 2005 19:43 schrieb John Hunter:

    > Hello, how does loc=0 (best) affects the placement of the
    > legend? I can't really figure out any influence. There is
    > space (on the upper left) where the legend could be
    > placed without hiding any lines but it's still placed on
    > the upper right.

If what you say is correct, then it is a bug. Please post a complete
example.

I’ll have a play to see if I can make this a bit
smarter.

John

Florian Lindner wrote:

···

<mailinglists@…606…>Matplotlib-users@lists.sourceforge.net