圖片標題太低(使用 LaTeX 檔案影像)

圖片標題太低(使用 LaTeX 檔案影像)

我正在上傳我用它創建的圖像gnuplot在我的文件上使用;

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

問題是它看起來像;

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

圖的標題太低了。我不知道這是 LaTeX 還是 gnuplot 的問題。我試圖找出減少 gnuplot 上邊距的方法,但無濟於事。

如何減少圖片和標題之間的間隙?

如果有人需要,這是我的 gnuplot 東西;

 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

答案1

看起來 gnuplot 的latex終端在繪圖周圍引入了一些空白區域。你可以看到它

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

產生

在此輸入影像描述

我不知道如何在 gnuplot 抑制這個邊距(很長時間沒有使用它;-)),但你可以從plot.tex.

該文件開頭為

% 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)是圖形的右上角和(0,0)左下角。修改(0,0)(0,40),儲存plot.tex,再次編譯,將得到:

在此輸入影像描述

如果您必須做很多這樣的圖形,我建議選擇另一個終端(eps、pdf、tikz)或使用pgfplots它可以呼叫 gnuplot 來計算貝塞爾函數。

答案2

另一種方法是透過pgfplotswithaddplotgunplotcapability 來繪製它。然後使用caption調整圖形和標題之間的間隙。

在此輸入影像描述

程式碼

\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}

相關內容