With Paul's suggestions (greatly appreciated!) I almost have this
thing working....there is still something strange going on in that
when I call get_window_extent() on the legend, I always get ones and
zeros no matter where it is...but that's for another post on another
This one, I hope, is an easy one. The last thing I need to do is
position the legend precisely. For example, the code below doesn't
quite position the top left corner of the legend at the top left
corner in the plot:
ax = pylab.gca()
# draw an X to make sure of coordinates.
It's close, but not there.....so the question becomes, how do I place
a legend exactly at the coordinates that I want?
On Sat, Oct 30, 2010 at 1:16 AM, Paul Ivanov <pivanov314@...287...> wrote:
Daniel Hyams, on 2010-10-29 23:48, wrote:
Thanks Paul! Your suggestion got me part of the way, but I've run
into another problem...I'm using draggable legends, I'm also wanting
to fetch the current position of the legend after a drag. The
draggable legend always updates 'loc', and not 'bbox_to_anchor', so
I'm afraid that I'm stuck manipulating 'loc' for my purposes and not
the bbox_to_anchor property.
Is there really no way to get the dimensions of a legend? It has to be
there somewhere, otherwise the legend wouldn't know where to draw
I'm replying to the list, so that someone correct me if I'm
wrong, or point out a better way of doing this.
there totally is a way to get the dimensions of a legend.
You can get it in pixel coordinates using
l = plt.legend()
bbox = l.get_window_extent()
or in axes coordinates using something like
bbox2 = bbox.transformed(l.axes.transAxes.inverted())
The bboxes have other handy attributes like p0,p1,x0,x1,y0,y1
etc, as well as methods like bbox.padded(), etc.
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
Matplotlib-users mailing list