5

I'm uploading an image I created with gnuplot on to my document using;

\begin{figure}[tbp]
\begin{center}
\input{plot.tex}
\caption{Graph caption}
\label{fig4}
\end{center}
\end{figure}

The problem is it looks like;

http://postimg.org/image/j4i4oylx9/

The figure caption is way too low. I can't figure out whether this is an issue with LaTeX or gnuplot. I've tried to figure out ways to reduce the margin on gnuplot but to no avail.

How do I decrease the gap from the picture and caption?

If anyone needs, this is my gnuplot stuff;

 set terminal latex
 set out 'plot.tex'
 set termoption dash

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

 unset colorbox


 plot besj1(x)  ls 1 title '$J_1(x)$',\
 besy1(x)  ls 11 title '$Y_1(x)$',  \

set label 5 '$J_1(x)$' at 2, 0.7
set label 6 '$Y_1(x)$' at 4.5, 0.45
set size 1, 0.75

unset key
set out

2 Answers2

2

It looks like gnuplot's latex terminal introduces some empty space around the plot. You can see it with

\documentclass{article}
\begin{document}
\begin{figure}
\centering
\fbox{\input{plot.tex}}
\caption{Graph caption}
\end{figure}
\end{document}

which produces

enter image description here

I don't know how to suppress this margin within gnuplot (long time without using it ;-)) but you can adjust it from plot.tex.

This file starts with

% GNUPLOT: LaTeX picture
\setlength{\unitlength}{0.240900pt}
\ifx\plotpoint\undefined\newsavebox{\plotpoint}\fi
\sbox{\plotpoint}{\rule[-0.200pt]{0.400pt}{0.400pt}}%
\begin{picture}(1500,900)(0,0)
\sbox{\plotpoint}{\rule[-0.200pt]{0.400pt}{0.400pt}}%

(1500,900) is figure's top right corner and (0,0) its bottom left corner. Change (0,0) to (0,40), save plot.tex, compile again and will get:

enter image description here

If you have to do a lot of figures like this, I'd suggest selecting another terminal (eps, pdf, tikz) or using pgfplots which can call gnuplot to compute Bessel functions.

Ignasi
  • 136,588
1

An alternative is to plot it via pgfplots with addplot and gunplot capability. Then use of caption to adjust the gap between the figure and the caption.

enter image description here

Code

\documentclass{article}
\usepackage[margin=0.5cm,papersize={12cm,10cm}]{geometry}
\usepackage{pgfplots}
\usepackage{tikz,pgfplotstable}
\usepackage[font=small,skip=0pt]{caption}
\pgfplotsset{compat=1.8}

\begin{document}

\begin{figure}[htbp]
\centering
%\input{plot.tex}
\begin{tikzpicture}
\begin{axis}[
width=10cm,
height=5cm,ymin=-1,ymax=1,
xmin=0,xmax=20,
]
\addplot[color=yellow,
solid, line width=1.0pt,
domain=0:20, samples=400]
gnuplot {besj1(x)};
\node at (axis cs: 6,0.5){$Y_1(x)$};
\addplot[color=blue,
solid, line width=1.0pt, restrict y to domain=-1:1,
domain=0:20,samples=400]
gnuplot {besy1(x)};
\node at (axis cs: 2,0.7){$J_1(x)$};
\end{axis}
\end{tikzpicture}
\caption{Graph caption}
\label{fig4}
\end{figure}

\end{document}
Jesse
  • 29,686