Hi. I've found myself in the position of (a) often having to plot data with specific views for either debugging or publication purposes. While this is often easy enough to write as a python script, I've found myself either rewritting the same code over again, or having to create a large number of command line parameters to specify exactly what type of plot is required. It occured to me that it might be nice to have a seperation of data and plotting (i.e. MVC) and that XML would work well for these purposes (e.g. libglade and renaissance) . For example, something like:
<figure title="Hodgkin and Huxley cell">
<subplot title="voltage" pos="1,1"><plot fn="readData" file="sim.dat" var="voltage"/></subplot>
<subplot title="m" pos="2,1">
<plot fn="readData" file="sim.dat" var="m" color='b' linewidth="2"/>
<plot fn="readData" file="sim.dat" var="h" color='g' linewidth="2"/>
<plot fn="readData" file="sim.dat" var="n" color='r' linewidth="2"/>
would be nice, and then all one would have to do is define the function 'readData'. Most likely, if all your data files are nearly the same, you would only have to define 'readData' once, and then depending on what type of plots you wanted, you could easily change the XML doc to fit your needs without having to rewrite more code.
I have some code to do this, which I quickly hacked together today. I'll probably be working on it for my own uses, but I thought I would check if this is something people might be interested in having in the pylab library..
p.s. I've had the traits-based config library almost done for a bit .. I just haven't had time to put the last finishing touches on it. I'll email it soon.
xmlplot.py (6.34 KB)