相关疑难解决方法(0)

如何使用ggplot2控制绘图的尺寸/大小

我正在使用ggplot2(分别是qplot)来生成一个带有Sweave的报告.现在我需要一些帮助来调整绘图的大小.我使用以下Sweave代码来包含它.

\begin{figure}[htbp]
\begin{center}
<<fig=true,echo=false>>=
print(mygraph)
@
\caption{MyCaption}
\end{center}
\end{figure}
Run Code Online (Sandbox Code Playgroud)

如果我添加一个宽度参数(如下图所示)来绘制图表,但是没有真正按比例缩小.

<<fig=true,echo=false,width=3>>=
Run Code Online (Sandbox Code Playgroud)

如果我使用ggsave()代替,我可以使用scale参数并影响生成的.pdf文件的大小.有没有办法影响绘图的尺寸而不保存它(因为.pdf是由Sweave生成的)?我需要添加到我的qplot代码中吗?

mygraph=qplot(date,value,data=graph1,geom="line",colour=variable,xlab="",ylab="")
+ scale_y_continuous(limits = c(-0.3,0.3))
Run Code Online (Sandbox Code Playgroud)

Thx提前提出任何建议!

r ggplot2

8
推荐指数
1
解决办法
1万
查看次数

在Sweave中将选项[keepaspectratio = true,scale = 0.75]添加到\ includegraphics {}

我有以下R代码

<<Q1b1, fig=TRUE>>=  
qqnorm(resid(model1), main=NULL)
@
Run Code Online (Sandbox Code Playgroud)

和我想的选项[keepaspectratio =真,标度= 0.75]添加到\ includegraphics {}呼叫,使得上述R代码块生成

\begin{figure}[ht]
\caption{}
\begin{center}
\includegraphics[keepaspectratio=true, scale = 0.75]{filename.pdf}
\label{fig:1}
\end{center}
\end{figure}
Run Code Online (Sandbox Code Playgroud)

我知道你可以使用\ {SweaveOpt宽度= X,HEIGHT = Y}指定的宽度和高度,但我想说明的规模和有它保持身材的宽高比时系统产生的.

是否有捷径可寻?

谢谢

r sweave

5
推荐指数
1
解决办法
9235
查看次数

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

我发现这个问题是关于改变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)

r ggplot2 sweave

2
推荐指数
1
解决办法
5808
查看次数

标签 统计

r ×3

ggplot2 ×2

sweave ×2