I mailed this to the matplotlib-users list, but it never showed, so
I'm trying this one. Apologies
if it shows up in both places :(

What I'm trying to do can be boiled down to the following:  I'm trying to

place a legend precisely, using the top left corner of legend as the
"sticky" point.  In other words, if I want to place the legend here:

+---------------------------------+-----------+

|                                 |           |
|                                 |  legend   |
|                                 |           |
|                   The plot...   |-----------+
|                                 |

|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |

+---------------------------------+

I would have thought that I would set bbox_to_anchor = (0,0,1,1), and loc =
(1,1).  I found out quickly, though, that this places the legend like this:

                                  +-----------+

                                  |           |
                                  |  legend   |
                                  |           |
+---------------------------------+-----------+

|                                 |
|                                 |
|                                 |
|                   The plot...   |
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |

+---------------------------------+

Which makes perfect sense from matplotlib's perspective.  So all I need to
do is figure out how tall the legend is, and subtract that off the y
coordinate before passing 'loc' off to matplotlib's legend.  I just can't

seem to figure out how to get that number.  I tried
self.ax.get_legend().get_frame().get_height(), but that just returns 1 all
the time.  I browsed all through the legend object (a live one) and just can't
find any numbers at all that look like the legend width/height, in any
coordinate

system.  I hope I'm missing something obvious!

Ascii art is fun! :)



-- 
Daniel Hyams
dhy...@gmail.com
------------------------------------------------------------------------------
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-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to