[SciPy-user] Quick and Dirty gnuplot

Lance Boyle lanceboyle at cwazy.co.uk
Fri Aug 6 18:24:11 CDT 2004


This talk of gnuplot reminded me of this gem:

http://ndevilla.free.fr/gnuplot/gnuplot.py


I modified it a bit to work with the excellent AquaTerm on Mac OS X:

import os
class gnuplot:
	def __init__(self):
		print "opening new gnuplot session..."
		self.session = os.popen("gnuplot","w")
	def __del__(self):
		print "closing gnuplot session..."
		self.session.close()
	def send(self, cmd):
		self.session.write(cmd+'\n')
		self.session.flush()
if __name__=="__main__":
	g1 = gnuplot()
	g1.send("set terminal aqua 0")
	
	# Your code here
	g1.send("plot sin(x)")
	
	del g1



More information about the SciPy-user mailing list