Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
share|improve this question
2  
Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Christian Hupfer May 9 at 4:36
    
It looks like a suboptimal bounding box for your figure but without a minimal working example, it's difficult to tell. –  Svend Tveskæg May 9 at 4:36
    
Why do you not use eps or pdf terminal for graphics output of gnuplot? –  Christian Hupfer May 9 at 4:37

2 Answers 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.

share|improve this answer

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.