Index: python/aubio/gnuplot.py
===================================================================
--- python/aubio/gnuplot.py	(revision 32fa8e816aaf24cce0c79dd1cab463fbbf0b9e26)
+++ python/aubio/gnuplot.py	(revision 0ab19df22676e5ef57ae16f014b7c0f6d4c91085)
@@ -163,17 +163,35 @@
   return Gnuplot.Data(x,y,with='lines')
 
-def gnuplot_create(outplot='',extension='',debug=0,persist=1, xsize=1., ysize=1.):
-	import Gnuplot
-        g = Gnuplot.Gnuplot(debug=debug, persist=persist)
-	if not extension or not outplot: return g
-	if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
-	elif extension == 'eps': ext, extension = '.eps' , 'postscript enhanced'
-	elif extension == 'epsc': ext, extension = '.eps' , 'postscript enhanced color'
-	elif extension == 'png': ext, extension = '.png', 'png'
-	elif extension == 'svg': ext, extension = '.svg', 'svg'
-	else: exit("ERR: unknown plot extension")
-	g('set terminal %s' % extension)
-	if outplot != "stdout":
-		g('set output \'%s%s\'' % (outplot,ext))
-	g('set size %f,%f' % (xsize, ysize))
-	return g
+def gnuplot_addargs(parser):
+  """ add common gnuplot argument to OptParser object """
+  parser.add_option("-x","--xsize",
+          action="store", dest="xsize", default=1., 
+          type='float',help="define xsize for plot")
+  parser.add_option("-y","--ysize",
+          action="store", dest="ysize", default=1., 
+          type='float',help="define ysize for plot")
+  parser.add_option("-d","--debug",
+          action="store_true", dest="debug", default=False, 
+          help="use gnuplot debug mode")
+  parser.add_option("-p","--persist",
+          action="store_false", dest="persist", default=True, 
+          help="do not use gnuplot persistant mode")
+  parser.add_option("-O","--outplot",
+          action="store", dest="outplot", default=None, 
+          help="save plot to output.{ps,png}")
+
+def gnuplot_create(outplot='',extension='', options=None):
+  import Gnuplot
+  g = Gnuplot.Gnuplot(debug=options.debug, persist=options.persist)
+  if not extension or not outplot: return g
+  if   extension == 'ps':  ext, extension = '.ps' , 'postscript'
+  elif extension == 'eps': ext, extension = '.eps' , 'postscript enhanced'
+  elif extension == 'epsc': ext, extension = '.eps' , 'postscript enhanced color'
+  elif extension == 'png': ext, extension = '.png', 'png'
+  elif extension == 'svg': ext, extension = '.svg', 'svg'
+  else: exit("ERR: unknown plot extension")
+  g('set terminal %s' % extension)
+  if outplot != "stdout":
+    g('set output \'%s%s\'' % (outplot,ext))
+  g('set size %f,%f' % (options.xsize, options.ysize))
+  return g
Index: python/aubioplot-audio
===================================================================
--- python/aubioplot-audio	(revision 32fa8e816aaf24cce0c79dd1cab463fbbf0b9e26)
+++ python/aubioplot-audio	(revision 0ab19df22676e5ef57ae16f014b7c0f6d4c91085)
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 
-import aubio.gnuplot, sys
+import sys
+from aubio.gnuplot import gnuplot_create,gnuplot_addargs,plot_audio
 
 usage = "usage: %s [options] -i soundfile" % sys.argv[0]
@@ -11,13 +12,5 @@
                           action="store", dest="filename", 
                           help="input sound file")
-        parser.add_option("-x","--xsize",
-                          action="store", dest="xsize", default=1., 
-                          type='float',help="define xsize for plot")
-        parser.add_option("-y","--ysize",
-                          action="store", dest="ysize", default=1., 
-                          type='float',help="define ysize for plot")
-        parser.add_option("-O","--outplot",
-                          action="store", dest="outplot", default=None, 
-                          help="save plot to output.{ps,png}")
+        gnuplot_addargs(parser)
         (options, args) = parser.parse_args()
         if not options.filename: 
@@ -35,6 +28,6 @@
   outplot = None
 
-g = aubio.gnuplot.gnuplot_create(outplot,extension,xsize=options.xsize, ysize=options.xsize)
-aubio.gnuplot.plot_audio(options.filename.split(','), g,
+g = gnuplot_create(outplot,extension,options)
+plot_audio(options.filename.split(','), g,
   xsize=options.xsize,
   ysize=options.ysize)
Index: python/aubioplot-spec
===================================================================
--- python/aubioplot-spec	(revision 32fa8e816aaf24cce0c79dd1cab463fbbf0b9e26)
+++ python/aubioplot-spec	(revision 0ab19df22676e5ef57ae16f014b7c0f6d4c91085)
@@ -6,5 +6,5 @@
 
 import sys
-from aubio.gnuplot import *
+from aubio.gnuplot import gnuplot_create,gnuplot_addargs,plot_spec 
 
 usage = "usage: %s [options] -i soundfile" % sys.argv[0]
@@ -22,16 +22,7 @@
                           action="store", dest="minf", default=0., 
                           type='float',help="lower frequency limit")
-        parser.add_option("-x","--xsize",
-                          action="store", dest="xsize", default=1., 
-                          type='float',help="define xsize for plot")
-        parser.add_option("-y","--ysize",
-                          action="store", dest="ysize", default=1., 
-                          type='float',help="define ysize for plot")
         parser.add_option("-l","--log",
                           action="store_true", dest="log", default=False, 
                           help="plot on a logarithmic scale")
-        parser.add_option("-O","--outplot",
-                          action="store", dest="outplot", default=None, 
-                          help="save plot to output.{ps,png}")
         parser.add_option("-B","--bufsize", type='int',
                           action="store", dest="bufsize", default=8192, 
@@ -40,4 +31,5 @@
                           action="store", dest="hopsize", default=1024, 
                           help="overlap size [default=1024]")
+        gnuplot_addargs(parser)
         (options, args) = parser.parse_args()
         if not options.filename: 
@@ -56,5 +48,5 @@
   outplot = None
 
-g = gnuplot_create(outplot,extension,xsize=options.xsize, ysize=options.ysize)
+g = gnuplot_create(outplot,extension,options)
 plot_spec(filename, g, log=options.log,
   maxf = options.maxf, minf = options.minf, 
