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: https://svn.sourceforge.net/svnroot/matplotlib/trunk/toolkits/mplsizer 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() frame.SetSizer(sizer) sizer.Add(a,name='a',expand=1) sizer.Add(b,name='b',all=0,left=1,border=0.2) sizer.Add(b2,name='b2') if more_plots: hsizer = mplsizer.MplBoxSizer(orientation='horizontal') hsizer.Add(c,name='c',option=1,align_bottom=1) hsizer.Add(d,name='d',align_centre=1) sizer.Add(hsizer,all=0,bottom=1,border=0.5,expand=1,option=1) frame.Layout() # triggers layout # It's naughty to use the private attribute, but, hey, this is for # debugging only, so it's OK, right? lowest.set_position(hsizer._rect) pylab.show() ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel