On Fri, May 6, 2011 at 5:55 AM, Chris Rodgers <chris.rodg...@berkeley.edu>wrote:

> The real solution of course is to calculate exactly where every piece
> of text actually is, detect overlaps, and adjust. That is certainly
> beyond my ability or inclination to implement. In the mean time, it
> would be nice to have a simple "idiot-proof" flag that blindly fixes
> some common problems.
>

I wrote a helper script awhile back to adjust spacing "automatically".

Code can be found here:
http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg18107.html

You can simply copy the code into a module (e.g. layout.py) that lives in
your python path, and then call "layout.tight_layout()" *right before* your
call to "plt.show()" (or "plt.savefig()").

It's pretty inefficient though because it has to draw the figure 3 different
times (once to calculate the size of subplots and again to calculate the
size of the figure, and then the final draw). There are some other issues,
which prevent inclusion in matplotlib (see discussion in link below), but it
works well for my purposes.

Best,
-Tony

Original post, with some discussion, can be found here:
http://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg06896.html

Note the code from the original post didn't work on some backends, so it's
probably best to use the code from the first link.
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to