Due to repeated emails by Eric Firing about how something like this
would be nice to have, I finally got around to packaging a little
utility I wrote. I uploaded it to the MPL source repository. The basic
idea is to create a layout engine for matplotlib. Not wanting to
(re-)invent an API, I decided simply to imitate the layout engine I knew
best, which is wxPython.
Disclaimer: This isn't bug-free, complete, or well-documented and this
announcement should merely be taken as a call to "commence hacking now".
That being said, I've used mplsizer for several figures for publication,
so I don't consider it that bad or incomplete, either.
Anyhow, the source code, licensed under the MIT license, is available at:
One note: aside from depending on matplotlib, this requires setuptools.
Sorry to those of you who hate setuptools, but it simply gives me tools
that make my life easier. If you want to change mplsizer to not require
setuptools, that's fine by me, but we should keep it setuptools compatible.
Here's the last part of the demo_basic.py script. "fig" is a matplotlib
Figure instance, "a","b","b2", and "lowest" are matplotlib Axes instances.
# Now perform the mplsizer stuff
import matplotlib.toolkits.mplsizer as mplsizer
frame = mplsizer.MplSizerFrame( fig )
sizer = mplsizer.MplBoxSizer()
hsizer = mplsizer.MplBoxSizer(orientation='horizontal')
frame.Layout() # triggers layout
# It's naughty to use the private attribute, but, hey, this is for
# debugging only, so it's OK, right?