Hi Eric, As far as I know, get_window_extent is meant to return the extent of the object in the display coordinate. And, as you may have noticed, often this is used to calculate the relative position of objects.
I quickly went through your patch and my guess is your implementation of get_window_extent is correct in this regard, but I haven't considered this seriously so I may be wrong. On the other hand, I guess the original problem you had is not related with the get_window_extents() method. The legend class has a _update_positions() method which is called before the legends are drawn. And you have to update positions of your handles within this method. In the simple patch below. I tried to implement some basic update code for the polycollections ( I also slightly adjusted the y-offsets. This is just my personal preference). See if this patch works for you. Regards, -JJ Index: lib/matplotlib/legend.py =================================================================== --- lib/matplotlib/legend.py (revision 6163) +++ lib/matplotlib/legend.py (working copy) @@ -532,6 +540,12 @@ elif isinstance(handle, Rectangle): handle.set_y(y+1/4*h) handle.set_height(h/2) + elif isinstance(handle, RegularPolyCollection): + offsets = handle.get_offsets() + xvals = [x for (x, _) in offsets] + yy = y + h + yvals=[yy-4./8*h,yy-3./8*h,yy-4./8*h] + handle.set_offsets(zip(xvals, yvals)) # Set the data for the legend patch bbox = self._get_handle_text_bbox(renderer) On Tue, Oct 7, 2008 at 12:15 AM, Erik Tollerud <[EMAIL PROTECTED]> wrote: > Does anyone have anything new here? I'm perfectly willing to > experiment, but I'm really at a loss as to what > get_window_extent(self,render) is supposed to do (clearly get some > window extent, but exactly what window and what coordinates the extent > is in is what is confusing me). > > On Tue, Sep 23, 2008 at 11:41 AM, John Hunter <[EMAIL PROTECTED]> wrote: >> On Tue, Sep 23, 2008 at 12:20 AM, Erik Tollerud <[EMAIL PROTECTED]> wrote: >>> Attached is a diff against revision 6115 that contains a patch to >>> improve the behavior of the legend function when showing legends for >> >> Erik, >> >> I haven't had a chance to get to this yet. Could you please also post >> it on the sf patch tracker so it doesn't get dropped, and ping us with >> a reminder in a few days if nothing has happened.... >> >> JDH >> > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Matplotlib-devel mailing list > Matplotlib-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel