Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiplot stacked over each other vertically, with same x axis in gnuplot

Following is the code I use and below that is my output. I want to remove all the spaces in between my subplots and the x labels. A sample of what I need is provided in the link at the end the only difference being I need all the boxes to be of same size.

set terminal jpeg

set output "mul.jpeg"

set multiplot

set xr[0:10]
set ylabel "y"
set format y ""
set key off

set size 1,0.25

set origin 0.0,0.0;
set xlabel "x"
plot sin(x)
replot sin(2*x)

set origin 0.0,0.25;
set format x ""
plot cos(x)
replot cos(2*x)

set origin 0.0,0.50;
set format x ""
plot sin(x)

set origin 0.0,0.75;
set format x ""
plot cos(x)

unset multiplot

multiplot_example

What I actually need is something like this:

https://inspirehep.net/record/1345236/files/hada_fig2.png

Thank you for any help!

like image 455
ZeroTwo Avatar asked Jun 07 '16 15:06

ZeroTwo


2 Answers

From gnuplot 5.0, you can use the solution offered by @Raphael_Roth of setting margins to zero, but should also use the margins option of multiplot, to allow space for the tic labels and xlabel at the bottom.

E.g,

set tmargin 0
set bmargin 0
set lmargin 1
set rmargin 1

set multiplot layout 4,1 margins 0.05,0.95,.1,.99 spacing 0,0

set xrange [0:10]
unset xtics
plot sin(x), sin(2*x)
plot cos(x), cos(2*x)
plot sin(x)

set xtics
plot cos(x)

unset multiplot
like image 131
Joce NoToPutinsWarInUkraine Avatar answered Sep 20 '22 02:09

Joce NoToPutinsWarInUkraine


One way is to use multiplot layout, but it's a hassle to get it nice with the labels and tics (as they overlapp or don't fit into the canvas)

set terminal jpeg

set output "mul.jpeg"

set tmargin 0
set bmargin 0
set lmargin 1
set rmargin 1

unset xtics
unset ytics
set multiplot layout 4,1

set xr[0:10]
plot sin(x), sin(2*x)
plot cos(x), cos(2*x)
plot sin(x)
plot cos(x)

unset multiplot

The other possibility is to set the margins and/or origin of each plot separately as explained in these SO answers: multiplot - stacking 3 graphs on a larger canvas and How do gnuplot margins work in multiplot mode?

like image 30
Raphael Roth Avatar answered Sep 24 '22 02:09

Raphael Roth