Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling gnuplot from python

Tags:

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 send the following python string as input to gnuplot:

"plot '%s' with lines, '%s' with points;" % (eout,nout) 

where 'eout' and 'nout' are the two filenames.

PS: I prefer not to use additional python modules (eg. gnuplot-py), only the standard API.

Thank You

like image 208
Andrei Ciobanu Avatar asked Jan 29 '10 12:01

Andrei Ciobanu


1 Answers

The subprocess module lets you call other programs:

import subprocess plot = subprocess.Popen(['gnuplot'], stdin=subprocess.PIPE) plot.communicate("plot '%s' with lines, '%s' with points;" % (eout,nout)) 
like image 185
sth Avatar answered Oct 09 '22 09:10

sth