Index: python/aubio/task/onset.py
===================================================================
--- python/aubio/task/onset.py	(revision cf34922f1fb0778fdc5bf7cd13650345f865ade0)
+++ python/aubio/task/onset.py	(revision bf8e1344a4dc8e764f1a86e4a833fcce0142a65b)
@@ -145,5 +145,5 @@
 		# prepare the plot
 		g = gnuplot_create(outplot=outplot, extension=extension)
-		
+		g('set title \'%s\'' % (re.sub('.*/','',self.input)))
 		if spectro:
 			g('set size %f,%f' % (xsize,1.3*ysize) )
@@ -155,21 +155,4 @@
 		g('set lmargin 3')
 		g('set rmargin 6')
-		g('set tmargin 0')
-		g('set format x ""')
-		g('set format y "%3e"')
-		g('set noytics')
-
-		for i in range(len(oplots)):
-			# plot onset detection functions
-			g('set size %f,%f' % (xsize,0.7*ysize/(len(oplots))))
-			g('set origin 0,%f' % ((len(oplots)-float(i)-1)*0.7*ysize/(len(oplots))))
-			g('set xrange [0:%f]' % (self.lenofunc*self.params.step))
-			g('set nokey')
-			g('set yrange [0:%f]' % (1.1*oplots[i][2]))
-			g('set y2tics ("0" 0, "%d" %d)' % (round(oplots[i][2]),round(oplots[i][2])))
-			g.ylabel(oplots[i][1])
-			if i == len(oplots)-1:
-				g.xlabel('time (s)',offset=(0,0.7))
-			g.plot(*oplots[i][0])
 
 		if spectro:
@@ -188,35 +171,52 @@
 			g('set tmargin 0')
 			g('set palette rgbformulae -25,-24,-32')
-			g.xlabel('')
+			g.xlabel('time (s)',offset=(0,1.))
 			g.ylabel('freq (Hz)')
+			g('set origin 0,%f' % (1.0*ysize) ) 
+			g('set format x "%1.1f"')
 			#if log:
 			#	g('set yrange [%f:%f]' % (max(10,minf),maxf))
 			#	g('set log y')
 			g.splot(Gnuplot.GridData(data,time,freq, binary=1, title=''))
-			g('set lmargin 3')
-			g('set rmargin 6')
-			g('set origin 0,%f' % (1.0*ysize) ) 
-			g('set format x "%1.1f"')
-			g.xlabel('time (s)',offset=(0,1.))
 		else:
 			# plot waveform and onsets
+			time,data = audio_to_array(self.input)
+			wplot = [make_audio_plot(time,data)] + wplot
 			g('set origin 0,%f' % (0.7*ysize) )
+			g('set size %f,%f' % (xsize,0.3*ysize))
+			g('set format y "%1f"')
+			g('set xrange [0:%f]' % max(time)) 
+			g('set yrange [-1:1]') 
+			g('set noytics')
+			g('set y2tics -1,1')
 			g.xlabel('time (s)',offset=(0,0.7))
-			g('set format y "%1f"')
-
-		g('set size %f,%f' % (1.*xsize, 0.3*ysize))
-		g('set title \'%s %s\'' % (re.sub('.*/','',self.input),self.title))
-		g('set tmargin 2')
-		# audio data
-		time,data = audio_to_array(self.input)
-		wplot = [make_audio_plot(time,data)] + wplot
-		g('set y2tics -1,1')
-
-		g('set xrange [0:%f]' % max(time)) 
-		g('set yrange [-1:1]') 
-		g.ylabel('amplitude')
-		g.plot(*wplot)
-		
+			g.ylabel('amplitude')
+			g.plot(*wplot)
+
+		# default settings for next plots
+		g('unset title')
+		g('set format x ""')
+		g('set format y "%3e"')
+		g('set tmargin 0')
+		g.xlabel('')
+
+		N = len(oplots)
+		y = 0.7*ysize # the vertical proportion of the plot taken by onset functions
+		delta = 0.035 # the constant part of y taken by last plot label and data
+		for i in range(N):
+			# plot onset detection functions
+			g('set size %f,%f' % ( xsize, (y-delta)/N))
+			g('set origin 0,%f' % ((N-i-1)*(y-delta)/N + delta ))
+			g('set nokey')
+			g('set xrange [0:%f]' % (self.lenofunc*self.params.step))
+			g('set yrange [0:%f]' % (1.1*oplots[i][2]))
+			g('set y2tics ("0" 0, "%d" %d)' % (round(oplots[i][2]),round(oplots[i][2])))
+			g.ylabel(oplots[i][1])
+			if i == N-1:
+				g('set size %f,%f' % ( xsize, (y-delta)/N + delta ) )
+				g('set origin 0,0')
+				g.xlabel('time (s)', offset=(0,0.7))
+				g('set format x')
+			g.plot(*oplots[i][0])
+
 		g('unset multiplot')
-
-
Index: python/aubio/task/pitch.py
===================================================================
--- python/aubio/task/pitch.py	(revision cf34922f1fb0778fdc5bf7cd13650345f865ade0)
+++ python/aubio/task/pitch.py	(revision bf8e1344a4dc8e764f1a86e4a833fcce0142a65b)
@@ -162,11 +162,8 @@
 
 			
-	def plotplot(self,wplot,oplots,titles,outplot=None,multiplot = 1, midi = 1, truth = 1):
-		from aubio.gnuplot import gnuplot_init, audio_to_array, make_audio_plot
+	def plotplot(self,wplot,oplots,titles,outplot=None,extension=None,xsize=1.,ysize=1.,multiplot = 1, midi = 1, truth = 1):
+		from aubio.gnuplot import gnuplot_create , audio_to_array, make_audio_plot
 		import re
 		import Gnuplot
-		# audio data
-		time,data = audio_to_array(self.input)
-		f = make_audio_plot(time,data)
 
 		# check if ground truth exists
@@ -177,30 +174,33 @@
 					title='ground truth')] + oplots
 
-		t = Gnuplot.Data(0,0,with='impulses') 
-
-		g = gnuplot_init(outplot)
+		g = gnuplot_create(outplot=outplot, extension=extension)
 		g('set title \'%s\'' % (re.sub('.*/','',self.input)))
+		g('set size %f,%f' % (xsize,ysize) )
 		g('set multiplot')
 		# hack to align left axis
 		g('set lmargin 4')
 		g('set rmargin 4')
-		# plot waveform and onsets
-		g('set size 1,0.3')
-		g('set ytics 10')
-		g('set origin 0,0.7')
+    # plot waveform
+		time,data = audio_to_array(self.input)
+		wplot = [make_audio_plot(time,data)]
+		g('set origin 0,%f' % (0.7*ysize) )
+		g('set size %f,%f' % (xsize,0.3*ysize))
+		#g('set format y "%1f"')
 		g('set xrange [0:%f]' % max(time)) 
 		g('set yrange [-1:1]') 
 		g('set noytics')
 		g('set y2tics -1,1')
-		g.xlabel('time (s)',offset=(0,0.8))
+		g.xlabel('time (s)',offset=(0,0.7))
 		g.ylabel('amplitude')
-		g.plot(f)
+		g.plot(*wplot)
+
+		# default settings for next plots
 		g('unset title')
-		# plot onset detection function
-
-
-		g('set size 1,0.7')
-		g('set origin 0,0')
-		g('set xrange [0:%f]' % max(time))
+		g('set format x ""')
+		g('set format y "%3e"')
+		g('set tmargin 0')
+		g.xlabel('')
+		g('set noclip one') 
+
 		if not midi:
 			g('set log y')
@@ -212,19 +212,24 @@
 			g('set yrange [%f:%f]' % (aubio_freqtomidi(self.params.pitchmin), aubio_freqtomidi(self.params.pitchmax)))
 			g('set y2tics %f,%f' % (round(aubio_freqtomidi(self.params.pitchmin)+.5),12))
-		g('set key right top')
-		g('set noclip one') 
-		g('set format x ""')
+		
 		if multiplot:
-			g('set tmargin 0')
-			for i in range(len(oplots)):
-				# plot onset detection functions
-				g('set size 1,%f' % (0.7/(len(oplots))))
-				g('set origin 0,%f' % ((len(oplots)-float(i)-1)*0.7/(len(oplots))))
+			N = len(oplots)
+			y = 0.7*ysize # the vertical proportion of the plot taken by onset functions
+			delta = 0.035 # the constant part of y taken by last plot label and data
+			for i in range(N):
+				# plot pitch detection functions
+				g('set size %f,%f' % ( xsize, (y-delta)/N))
+				g('set origin 0,%f' % ((N-i-1)*(y-delta)/N + delta ))
+				g('set nokey')
 				g('set xrange [0:%f]' % max(time))
-				g('set nokey')
 				g.ylabel(titles[i])
-				g.xlabel('')
+				if i == N-1:
+					g('set size %f,%f' % (xsize, (y-delta)/N + delta ) )
+					g('set origin 0,0')
+					g.xlabel('time (s)', offset=(0,0.7))
+					g('set format x')
 				g.plot(oplots[i])
 		else:
+			g('set key right top')
 			g.plot(*oplots)
 		g('unset multiplot')
