Daniel Hyams <dhy...@gmail.com> writes:

> I was playing around with draggable legends, and some strange things started
> happening (exception down in the depths of beckend_agg.py, accompanied by a
> long stack trace).  To make a long story short, I can reproduce this in the
> draggable_legend.py example on the matplotlib website.  All you have to do
> is change line 7 [...] to
>
> l = ax.legend(bbox_to_anchor=(.1,.1))

Apparently this creates a bounding box with zero width and height, which
causes NaNs to appear in various transforms later on. It seems that you
can get the same placement of the legend with

l = ax.legend(bbox_to_anchor=(0,0,.1,.1))

which creates a non-degenerate bounding box that doesn't have this
problem. A possibly simpler option is

l = ax.legend(loc=(-0.2,0.1))

which sets the position of the lower-left corner of the legend box so
you'll need to tweak the coordinates from what you used with
bbox_to_anchor.

> I'm sure that I'm not understanding the proper usage of
> bbox_to_anchor.  

I'm not sure either. It seems that the two-number form of the bounding
box is meant to create a degenerate bounding box so that any kind of
location specifier ("upper right", "lower center", etc) will always hit
that exact place, but perhaps naturally that makes it difficult to move
the box around.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to