Est*_*oza 3 latex r tikz ggplot2
我目前正在使用 Rggplot2
和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()
Run Code Online (Sandbox Code Playgroud)
和乳胶代码:
\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}
Run Code Online (Sandbox Code Playgroud)
我想知道如何通过 ggplot2
消除标题和图形之间的巨大空间。
附言。R版本:3.2.3,ggplot2
版本:2.1.0,tikzDevice
版本:0.10-1。我从 Tobias Oetiker 的《LaTeX 2e 不太简短的介绍》 ,版本 5.05,第 116 页中获取了第二个图的代码。
好久没问这个问题了,但我还是想回答一下到底是什么问题。
正如您在这个问题中看到的关于\input{} 和 \include{} 之间的差异\include{}
,问题与执行\clearpage
before 和 after的事实有关\include{}
,它生成了我正在讨论的空白。
另一方面,使用\input{}
相当于将代码复制并粘贴到 LaTeX 文档中,这将防止出现空格。
归档时间: |
|
查看次数: |
9223 次 |
最近记录: |