legend(loc='best') not so great

OK, I've attached my sanitized example

Benjamin Root wrote:

sanitized.py (1.72 KB)

···

On Tue, Sep 11, 2012 at 9:29 AM, Neal Becker > <ndbecker2@...287...> wrote:

I tried a scatterplot with legend(loc='best'), but the legend
appears on the upper right, covering a data point. There is nothing
anywhere
in the graph on the upper left, which is where 'best' should go.

A small, self-contained example would be most useful. The logic for 'best'
isn't the greatest, but it should work in most cases. If you could provide
an example of where this blatantly breaks, it might uncover a bug.

Cheers!
Ben Root

OK, I've attached my sanitized example

ImportError: No module named pandas.

Can you provide an example that doesn't depend on pandas?

···

On Tue, Sep 11, 2012 at 3:34 PM, Neal Becker <ndbecker2@...287...> wrote:

Benjamin Root wrote:

On Tue, Sep 11, 2012 at 9:29 AM, Neal Becker >> <ndbecker2@...287...> wrote:

I tried a scatterplot with legend(loc='best'), but the legend
appears on the upper right, covering a data point. There is nothing
anywhere
in the graph on the upper left, which is where 'best' should go.

A small, self-contained example would be most useful. The logic for 'best'
isn't the greatest, but it should work in most cases. If you could provide
an example of where this blatantly breaks, it might uncover a bug.

Cheers!
Ben Root

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Damon McDougall
http://www.damon.is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

I was playing with this example to remove the pandas stuff, and It
looks a lot like the check for the best legend location is just not
accounting correctly for the multiple legend entries in this case.
Here is an even more minimal example, that I think reproduces the same
problem as Neal's original example.

colors = ['b','g','r']
for n in range(3):
    plt.scatter([n,],[n,],color=colors[n])
plt.legend(['foo','foo','foo'],loc='best')

Note that if you just put one legend name in there, the location is
perfectly fine, it is just as it extends downward for the second and
third names, that it covers over the point.

FYI: Im using v1.1.0 mpl, in EPD 7.2.

HTH,
Aronne

···

On Tue, Sep 11, 2012 at 10:49 AM, Damon McDougall <damon.mcdougall@...287...> wrote:

On Tue, Sep 11, 2012 at 3:34 PM, Neal Becker <ndbecker2@...287...> wrote:

OK, I've attached my sanitized example

ImportError: No module named pandas.

Can you provide an example that doesn't depend on pandas?

Aronne, thanks for taking the time to produce a nice example. I can
now recreate the problem. I'm not sure how invasive it will be to fix
this, so it possibly won't make it in for version 1.2, but possibly a
bugfix release after the fact.

For anyone who's interested, here's the github issue:
https://github.com/matplotlib/matplotlib/issues/1235

···

On Wed, Sep 12, 2012 at 5:57 PM, Aronne Merrelli <aronne.merrelli@...287...> wrote:

On Tue, Sep 11, 2012 at 10:49 AM, Damon McDougall > <damon.mcdougall@...287...> wrote:

On Tue, Sep 11, 2012 at 3:34 PM, Neal Becker <ndbecker2@...287...> wrote:

OK, I've attached my sanitized example

ImportError: No module named pandas.

Can you provide an example that doesn't depend on pandas?

I was playing with this example to remove the pandas stuff, and It
looks a lot like the check for the best legend location is just not
accounting correctly for the multiple legend entries in this case.
Here is an even more minimal example, that I think reproduces the same
problem as Neal's original example.

colors = ['b','g','r']
for n in range(3):
    plt.scatter([n,],[n,],color=colors[n])
plt.legend(['foo','foo','foo'],loc='best')

Note that if you just put one legend name in there, the location is
perfectly fine, it is just as it extends downward for the second and
third names, that it covers over the point.

FYI: Im using v1.1.0 mpl, in EPD 7.2.

HTH,
Aronne

--
Damon McDougall
http://www.damon.is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom