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
> itself ;)

Hi Daniel,

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()
  bbox.width,bbox.height

or in axes coordinates using something like

  bbox2 = bbox.transformed(l.axes.transAxes.inverted())
  bbox2.width,bbox2.height

The bboxes have other handy attributes like p0,p1,x0,x1,y0,y1
etc, as well as methods like bbox.padded(), etc.

best,  
-- 
Paul Ivanov
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 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to