相关疑难解决方法(0)

LaTeX 中 tikzDevice 和 ggplot2 生成的标题和图形之间的空白过多

我目前正在使用 Rggplot2tikzDevice包来生成图形并在文档中介绍它们LaTeX,但我正在努力解决图形和标题之间产生的大空白,正如您在比较图像时看到的那样(我已手动突出显示空格以使其更清晰):

ggplot2 绘图 tikz图

这是我的 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)

我想知道如何 …

latex r tikz ggplot2

3
推荐指数
1
解决办法
9223
查看次数

标签 统计

ggplot2 ×1

latex ×1

r ×1

tikz ×1