在Sweave中更改ggplot2绘图的大小,而不会使文本/数字不成比例地大

Ric*_*ron 2 r ggplot2 sweave

我发现这个问题是关于改变Sweave中ggplot2图的大小.我添加了Sweaveopts{width=3, height=3}它,它确实缩小了绘图的大小,但它没有缩小文本.所以最后,轴上的所有数字都重叠了.

有没有办法在Sweave中缩放整个ggplot2图,这样我就不必手动缩放原始ggplot2调用中的每个组件?这似乎是我应该做的事情,但我无法在ggplot2书籍或网站上找到它.谢谢!

FWIW,这是我在Sweave的电话:

\SweaveOpts{width=3, height=3}
\begin{figure}
\begin{center}
<<fig=TRUE>>=
print(plot.m)
@
\end{center}
\caption{stuff}
\label{fig:stuff}
\end{figure}
Run Code Online (Sandbox Code Playgroud)

并且生成ggplot2图的调用:

plot.m <- ggplot(temp, aes(date, spread)) + geom_bar(stat="identity") + scale_x_date(major="years", minor="months")
Run Code Online (Sandbox Code Playgroud)

Dir*_*tel 6

它基本上是一个Sweave FAQ.谷歌和你会发现一个巨大的点击率.

一种方法是将文件写入pdf(无缩放),然后缩放\includegraphics命令.我只是看了几天前完成的小插图,我想要的东西和页面一样宽,我做了:

\begin{figure}[t!]
  \centering
<<someLabel,fig=TRUE,width=8>>=
## some R code omitted
print(dotplot(foo ~ bar | someFactor, group=someThing, 
              data=someDF, layout=c(1,3),
              xlab="some X label", ylab="",
              key=simpleKey(text=c("A","B"), space="top")))
@
  \caption{Some caption.}
  \label{fig:someLabel}
\end{figure}
Run Code Online (Sandbox Code Playgroud)

一些基本上只是Sweave选项级别的一个宽度尺寸.我发现小值不能很好 - 所以尝试更大的东西,例如6或7英寸.