我目前使用R的ggplot2
和tikzDevice
包生成图形,并将它们介绍在LaTeX
文档中,但我遇到了图片和标题之间产生的大量空白,如果你对比这些图片,你会看到这一点(我手动标记了空白部分以使其更清晰):
以下是我的最小工作示例(MWE):
R代码:
library(ggplot2)
library(tikzDevice)
set.seed(1)
x <- rnorm(200)
tikz(file = "Rplots.tex", width = 4, height = 4)
qplot(x, geom = "histogram")
dev.off()
还有 LaTeX 代码:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\include{Rplots}
\caption{\texttt{ggplot2} plot.}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[scale=3]
\clip (-0.1,-0.2)
rectangle (1.8,1.2);
\draw[step=.25cm,gray,very thin]
(-1.4,-1.4) grid (3.4,3.4);
\draw (-1.5,0) -- (2.5,0);
\draw (0,-1.5) -- (0,1.5);
\draw (0,0) circle (1cm);
\filldraw[fill=green!20!white,
draw=green!50!black]
(0,0) -- (3mm,0mm)
arc (0:30:3mm) -- cycle;
\end{tikzpicture}
\caption{\texttt{tikz} plot.}
\end{figure}
\end{document}
我想知道如何通过ggplot2
消除标题和图之间的大间距。
附注:R版本:3.2.3,ggplot2
版本:2.1.0,tikzDevice
版本:0.10-1。我从Tobias Oetiker的《LaTeX 2e简介》第5.05版116页中获取了第二个图的代码。