How to reduce image size in sweave?

点点圈 提交于 2020-01-03 15:36:36

问题


How to reduce image size in sweave?

\documentclass[a4paper]{article}

\title{Sweave Example 1}
\author{Friedrich Leisch}

\begin{document}

\maketitle

In this example we embed parts of the examples from the
\texttt{kruskal.test} help page into a \LaTeX{} document:

<<>>=
data(airquality)
library(ctest)
kruskal.test(Ozone ~ Month, data = airquality)
@
which shows that the location parameter of the Ozone 
distribution varies significantly from month to month. Finally we
include a boxplot of the data:

\begin{center}
<<fig=TRUE,echo=FALSE>>=
boxplot(Ozone ~ Month, data = airquality) ## reduce image size so that can fit in window.
@
\end{center}

\end{document}

Regards


回答1:


Try knitr instead Sweave. See out.width and out.height options.

Your example would look like this:

\documentclass[a4paper]{article}

\title{Sweave Example 1}
\author{Friedrich Leisch}

\begin{document}

\maketitle

In this example we embed parts of the examples from the
\texttt{kruskal.test} help page into a \LaTeX{} document:

<<>>=
data(airquality)
library(ctest)
kruskal.test(Ozone ~ Month, data = airquality)
@
which shows that the location parameter of the Ozone 
distribution varies significantly from month to month. Finally we
include a boxplot of the data:

<<plot,fig.align="center",out.width="0.8\\linewidth",echo=FALSE>>=
boxplot(Ozone ~ Month, data = airquality) ## reduce image size so that can fit in window.
@

\end{document}


来源:https://stackoverflow.com/questions/10308955/how-to-reduce-image-size-in-sweave

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!