[R] Setting default plot size in Sweave
Marc Schwartz
marc_schwartz at me.com
Fri Jun 26 00:12:14 CEST 2009
On Jun 25, 2009, at 4:47 PM, Frank E Harrell Jr wrote:
> Dear Colleagues:
>
> I have used
>
> \SweaveOpts{prefix.string=plot, eps = FALSE, pdf = TRUE}
> \SweaveOpts{width=5, height=4}
>
> <<fig=T>>=
> plot(...)
> @
>
> But the figure still has a width of 80% of the text width, the
> default set up by Sweave, which issues a LateX command in Sweave.sty
> of \setkeys{Gin}{.8\textwidth}. Sweave.sty has a command
> \ifthenelse{\boolean{Sweave at gin}}{\setkeys{Gin}{width=0.8\textwidth}}
> {}% but I don't know how to set some parameter 'gin' to prevent the
> setkeys from being executed.
>
> I would like to be able to set the default graph dimensions at the
> start of the document and to only specify height and width inside
> <<>>= when I want to depart from that default.
>
> Thanks for any assistance.
>
> Frank
Frank,
See section 4.1.2 of the Sweave manual on page 14:
http://www.statistik.lmu.de/~leisch/Sweave/Sweave-manual.pdf
You can use the following *after* the \begin{document} directive:
\setkeys{Gin}{width=0.8\textwidth}
The above is the default. Reset it to what you would like.
Note, as per that manual page, that the Sweave options 'height' and
'width' affect the size of the PDF and EPS files created, but it is
the above command that controls the size of the image in the document
itself.
HTH,
Marc
More information about the R-help
mailing list