import os import time class MyGnuPlot: 'use this to open a gnuplot session' session = '' def __init__(self, debug): self.debug = debug if self.debug >= 1: print "opening new gnuplot session..." self.session = os.popen("gnuplot","w") def __del__(self): if self.debug >= 1: print "closing gnuplot session..." self.session.close() def send_command(self, filename): if self.debug >= 1: print "gnuplot load properties from %s" %filename self.session.write("load '%s'\n" %filename) self.session.flush() try: output = self.session.read() except: pass def send_kill(self): self.session.write('\n') self.session.flush()