如何通过 Sweave 在 minipage 中使用 ggplot2 图形?
这是我的代码,应该显示到彼此相邻的图形,但未能这样做。事实上,sweave 部分没有被解释。
\begin{figure}[h]
\begin{center}
\begin{minipage}[t]{.485\linewidth} %
<<fig=true,echo=false>>=
print(graph2)
@
\newline{\color{red}{\caption{\label{idx}Graph one}}}
\end{minipage}
\hspace{.02\linewidth}
\begin{minipage}[t]{.485\linewidth}%
<<fig=true,echo=false>>=
print(graph2)
@
\newline{\color{red}{ \caption{\label{pb}Graph two}}}
\end{minipage}
\end{center}
\end{figure}
graph1,graph2 只是 qplot 创建的任何给定图表。这两个图表在小型页面之外都可以正常工作。我知道这个主题已经存在,但不知何故我无法找到解决方案来使其适用于像这样的其他人 一个。
另外,我还有一个小问题:阻止 Sweave 生成 .eps 和 .pdf 的论点是什么?手册只是说这是默认的。不过我确信我只使用 pdflatex,因此不需要 .eps。
Here's my code that's supposed to display to graphics next to each other, but fails to do so. In fact the sweave part is not interpreted.
\begin{figure}[h]
\begin{center}
\begin{minipage}[t]{.485\linewidth} %
<<fig=true,echo=false>>=
print(graph2)
@
\newline{\color{red}{\caption{\label{idx}Graph one}}}
\end{minipage}
\hspace{.02\linewidth}
\begin{minipage}[t]{.485\linewidth}%
<<fig=true,echo=false>>=
print(graph2)
@
\newline{\color{red}{ \caption{\label{pb}Graph two}}}
\end{minipage}
\end{center}
\end{figure}
graph1,graph2 is just any given graph created by qplot. Both graphs work just fine outside a minipage. I know this topic has been around, but somehow I could not get solutions to got that worked for others like this one.
Plus I have a little side question: What's the argument to prevent Sweave from generating both .eps and .pdf ? The manual just states that it is the default. However I am sure that I just use pdflatex and hence do not need .eps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
呃,这实际上是作弊,但我在约翰的博客上找到了一个很好的解决方法。它没有使用 minipage,而是通过使用 subfigure 来完成它。 Subfigure 使用 Sweave 没有任何问题。好的!
如果您对此解决方案感兴趣,请检查此网站。我仍然想知道如何使用 minipage 来做到这一点:)
Eh, this is actually cheating, but a found a nice workaround on John's blog. It's not using minipage but it's getting it done by using subfigure. Subfigure did not have any problems with Sweave. Nice!
If you are interested in this solution check this site. Still i´d like to know how to do it with minipage :)
将
\hspace
替换为\hfill
就可以了。这些图来自 ggplot 文档。minipage
也可以很好地并排放置两个xtable
,或者一个表格和一个绘图。Replacing
\hspace
with\hfill
does the trick. The plots are from theggplot
documentation.minipage
also works nicely for putting twoxtable
side by side, or a table and a plot.