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.
--- lib/matplotlib/legend.py (revision 6163)
+++ lib/matplotlib/legend.py (working copy)
@@ -532,6 +540,12 @@
elif isinstance(handle, Rectangle):
+ elif isinstance(handle, RegularPolyCollection):
+ offsets = handle.get_offsets()
+ xvals = [x for (x, _) in offsets]
+ yy = y + 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 <erik.tollerud@...149...> 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 <jdh2358@...149...> wrote:
On Tue, Sep 23, 2008 at 12:20 AM, Erik Tollerud <erik.tollerud@...149...> wrote:
Attached is a diff against revision 6115 that contains a patch to
improve the behavior of the legend function when showing legends for
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....
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
Matplotlib-devel mailing list