Charts
Grant Edwards
grant at nowhere.
Tue Feb 1 18:13:51 EST 2000
In article <slrn89encl.mp4.jblaine at shell2.shore.net>, Jeff Blaine wrote:
>I had this very same need recently. I got all excited about the Gnuplot
>module until I found out that it requires the Numeric C extension to Python.
>Was immediately disinterested, as I saw no reason for a pipe-based wrapper
>to require a C extension.
>
>I ended up doing the following
>
> [ ... snip ... ]
> # Create a data file here with the full path stored in 'tmpfilename'
> gnuplot = os.popen('gnuplot', 'w')
> gnuplot.write('set terminal gif\n')
> gnuplot.write('set output "' + myfilename + '"\n')
> gnuplot.write('set format "%.0f"\n')
> gnuplot.write('plot "' + tmpfilename + '" with lines\n')
> gnuplot.flush()
> gnuplot.close()
> [ ... snip ... ]
If you want, you can send the data down the pipe instead of
creating a tempfile. From the gnuplot help help on plot
special-filenames:
`'-'` is intended for situations where it is useful to have
data and commands together, e.g., when `gnuplot` is run as a
sub-process of some front-end application. Some of the demos,
for example, might use this feature. For example:
plot '-','-'
2
4
6
e
10
12
14
e
>From the Python end, this would be something like:
gnuplot.write('plot "-" with lines\n')
gnuplot.write(dataString) # data with a newline after each point
gnuplot.write('e\n')
--
Grant Edwards grante Yow! I feel like a wet
at parking meter on Darvon!
visi.com
More information about the Python-list
mailing list