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')
Calling gnuplot from python