I\'ve a python script that after some computing will generate two data files formatted as gnuplot input.
How do I \'call\' gnuplot from python ?
I want to se
Subprocess is explained very clearly on Doug Hellemann's Python Module of the Week
This works well:
import subprocess
proc = subprocess.Popen(['gnuplot','-p'],
shell=True,
stdin=subprocess.PIPE,
)
proc.stdin.write('set xrange [0:10]; set yrange [-2:2]\n')
proc.stdin.write('plot sin(x)\n')
proc.stdin.write('quit\n') #close the gnuplot window
One could also use 'communicate' but the plot window closes immediately unless a gnuplot pause command is used
proc.communicate("""
set xrange [0:10]; set yrange [-2:2]
plot sin(x)
pause 4
""")