Thanks JJ!

It does, and you are exactly right, letting the legend "grow" downward while holding the value of the lower left corner doesn't make sense.. I tried calculating an offset, but the patch is a much nicer fix!

Soren

On Thu, Feb 26, 2009 at 9:27 PM, Jae-Joon Lee <lee.j.joon@gmail.com> wrote:
On Thu, Feb 26, 2009 at 4:51 AM, Søren Nielsen
<soren.skou.nielsen@gmail.com> wrote:
> I've tried placing a legend using the loc = (x,y) .. and the legend is moved
> where I want it. the problem is, when I add new lines to the plot.. the
> legend grows, but upwards.. so the lower left point of the legend box is
> constant.. but that's not the logical way for a legend box to grow..
> shouldn't it grow downwards, just like when I use the standard loc = 1
> (upper right position) .

Well, technically, legend never grows. Whenever you call legend(), a
new legend instance is created and the old one is just destroyed.
Anyhow, as far as I can tell, the (x,y) coordinates given to the *loc*
parameter has been the coordinate of the lower left corner of the
legend (but I don't think this is clearly specified in the
documentation). Therefore, I don't think it is a good idea to make the
legend grow(?) downward while you're supplying a fixed coordinate of
the lower left corner. This is hardly possible and it seems to make
little sense to me.

Anyhow, I just submitted a patch to the svn that add an optional
*bbox_to_anchor* argument for the legend class. This lets you specify
the bbox that the legend will be anchored (the default is the bbox of
the parent).

For example,

legend(loc="upper left", bbox_to_anchor=[0.0, 0.5])

will create an legend with its upper left corner at (0.0, 0.5), and it
will grow downward. Note that when len(bbox_to_anchor)==2, a bbox with
zero width and zero height is created.

I hope this suits your need.

-JJ

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users