Here is an example I made to generate a multiple plots by gnuplot. I don’t want that the 3 plots have space in between the x-axis. So the trick thing is: set the margin (r, l, t,b) very smaller,e.g. 0.01. Then the output looks “like” 3 stacked plots. You can modify it by 3 connected plots in a row (left, middle, right).
The plot is shown here:

The scripts is pasting here:
=========================
set terminal postscript
set output “data.ps”
unset key
NX=1; NY=3
DX=0.01; DY=0.01; SX=0.85; SY=0.25
set bmargin DX; set tmargin DX; set lmargin DY; set rmargin DY
## set the margin of each side of a plot as small as possible
## to connect each plot without space
set size SX*NX+DX*1.5,SY*NY+DY*1.8
set multiplot
##—— First Figure–bottom
set size SX,SY
set xrange [0:140]
set yrange [-0.9:0.9]
set ytic -0.6,0.3,0.6 ### from -0.6 to 0.6 with 0.3 interval
set origin DX,DY;
plot sin(x)
###——Second Figure—middle
set origin DX,DY+SY;
unset xtics
plot sin(x**2)
##——- Third Figure—-top
set origin DX,DY+SY*2
plot cos(x)
unset multiplot
[...] gnuplot By maldacena http://kpwu.wordpress.com/2007/11/20/gnuplot-make-a-multiplot-3-stacked-plots/ [...]
Pingback by gnuplot « A Second Life — January 25, 2009 @ 10:34 pm |
This is a nice script. If I want to include the x label and ylabel what else should I include?
Comment by prakash — March 3, 2009 @ 4:10 am |
just add the lines in proper places.
e.g.
set xlabel time
set ylabel intensity
Comment by kpwu — March 3, 2009 @ 8:12 am |
Good ! What if I wish to also place a ylabel. The stack of three plots becomes a complete mess. I have tried offset etc. and the mess gets worse. Any solution ?
- Atish .
Comment by Atish — March 26, 2009 @ 12:45 pm |
Sorted out with ‘set lmargin’. Thanks !
Comment by Atish — March 26, 2009 @ 12:51 pm |
Meanwhile, gnuplot supports automatic layout for stacked plots.
See the demo (scroll to bottom):
http://gnuplot.sourceforge.net/demo_4.3/layout.html
Comment by Walter — July 27, 2009 @ 9:28 am |
I want to add xtics at different plot in the stack.
What have to do?
Thanks
K.S.
Comment by Kanchan Sarkar — July 17, 2010 @ 4:41 pm |
Again How can one add title to different plots in the stack?
Comment by Kanchan Sarkar — July 17, 2010 @ 4:52 pm |
I got answers.
Comment by Kanchan Sarkar — July 17, 2010 @ 5:54 pm |
Hi,
Thank you for the example. I have a question about it. The output that I get doesn’t look like the one you provided. Do you know what the problem might be?
Thanks!
Comment by randaasad — July 20, 2011 @ 12:22 am |
perhaps it’s about the version of GnuPlot. The script shown at here was created 4 years ago. I may use GnuPlot 3.5 at that time. I was having lots of problem using my old scripts for GnuPlot 4.0 and above.
Comment by kpwu — July 20, 2011 @ 1:00 am |