0
votes

I have to plot 4 graphs without vertical spaces between them and add a caption in my tex document. The problem is that the caption is overlapped with the x-axis label because of the zero bottom margin, I think.

The gnuplot file is something like this

set term epslatex
set output 'foo.tex'

set xrange [-1:1]
set yrange [-1:1]

set multiplot layout 4,1
set ylabel '$y$'
unset xlabel
unset xtics
set tmargin 0
set bmargin 0
plot x w lines
plot x*x w lines
plot x*x*x w lines
set xlabel '$x$'
set xtics
plot x*x*x*x w lines
unset multiplot

and the tex file is

\documentclass[a4paper,11pt]{toptesi}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\input{foo}
\caption{bla bla}
\end{figure}

\end{document}

and the "bla bla" comes over the x label... I tried to put an set bmargin "something" before the last graph but this have the problem that the last graph hasn't the size of the first three anymore... How to fix the size of plots but allow a bmargin for the tex caption?

1
I think there are more elegant ways to solve the problem than work with margins...bluePhlavio
@bluePhalvio Why not just use vspace in your tex document. Like vspace 0.15in or whatever vertical spacing is useful. And you would insert this between \input{foo} and \caption{bla bla}Zahaib Akhtar
with backslash offcourse: \vspace {0.15in}Zahaib Akhtar
Thanks a lot!!! It's so simple and works fine!bluePhlavio
need I say that it adds vertical space :)Zahaib Akhtar

1 Answers

0
votes

Try this code...

set term epslatex size <width> <height>
set output 'foo.tex'

set xrange [-1:1]
set yrange [-1:1]

set multiplot
# setup sizes of single plots
set size 1,.25
set ylabel '$y$'
unset xlabel
unset xtics
set tmargin 0
set bmargin 0
# set bottom left corner of current plot
set origin 0,.75
plot x w lines
set origin 0,.5
plot x*x w lines 
set origin 0,.25
plot x*x*x w lines
set xlabel '$x$'
set xtics 
# set bmargin back
set bmargin 3 #might be enought for place xlabel, try it...
set origin 0,0 
plot x*x*x*x w lines

unset multiplot
set out
set term pop

But... The bottom panel is smaller than others, so you must increase vertical size of bottom panel (using set size 1, a) a>0.25 and decrease vertical size of others (set size 1, b before each plot command) and satisfy that a+3b=1. This fine tuning will depend on size parameter of epslatex terminal.

Much much better solution might be this:

 ...
 set size 0,.25
 set tmargin 0
 set bmargin 1
 set origin .75,0
 plot ...
 set tmargin -1
 set bmargin 2
 set origin .5,0
 plot ...
 set tmargin -2
 set bmargin 3
 set origin .25,0
 plot ...
 set tmargin -3
 set bmargin 4
 set origin .25,0
 plot ...

Now we might have enough space for bottom xlabel and all of the panels have same height. Unfotunatelly gnuplot 4.6.3 interprets tmargin -3 as tmargin 0. So we can't use it right now... May be in some newer version.