[SciPy-dev] gplt suggestion: initcmd
Michael J Gruber
michaeljgruber+scipy at fastmail.fm
Fri Jul 8 08:24:08 EDT 2005
SciPy version: 0.3.2
When using the gplt module for batch processing plots there are two
problems:
- gplt sets the default terminal to X11, so that you have to have X
running (or Xfb).
- gplt sends "reset" for every plot", and implements set commands (range
etc) as "replots". In particular, ranges get reset when setting up
output to a file!
As an example, I want to generate 500 plots depending on a parameter,
but with the same range so that the plots fit together as an animation.
The attached diffs change "plot" and "_init_plot" so that plot has an
optional keyword parameter "initcmd". If it is not specified or None,
plot behaves as before (sending a "reset" to gnuplot for every plot).
If specified, it is sent (instead of reset) verbatim to gnuplot.
This allows to do something like the following:
# xvals is an arry of x coordinates
initcmd='set yrange [-5:40]; set xrange [0:1]; set terminal jpeg size
1000,750;
for j in range(500):
plotdata = myplotproc(j)
gplt.plot(xvals,plotdata,"initcmd=initcmd+'set output
"'+prefix+('%0.3d.jpeg"' % j))
(The mailer may introduce linebreaks in the code above.)
That way, there are no replots involved, no X needs to be running. One
could arrange for range and term to be set only once, but this no
performance issue.
I'll appreciate any feedback.
Cheers,
Michael
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: interface.py.diff
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20050708/69d6d909/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pyPlot.py.diff
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20050708/69d6d909/attachment-0001.ksh>
More information about the SciPy-Dev
mailing list