[R] Sweave - landscape figure

Duncan Murdoch murdoch.duncan at gmail.com
Thu Aug 4 21:58:12 CEST 2011


On 04/08/2011 3:40 PM, Eduardo M. A. M. Mendes wrote:
> Dear R-users
>
> I am trying to understand how Sweave works by running some simple examples.  In the example I am working with there is a chunk where the R-commands related to plotting a figure are placed.  When running R CMD Sweave … , pdflatex the output is a portrait figure.  I wonder whether it would be possible to change the orientation to landscape (not in the latex file but in Rnw file).
>

Sweave can change the height and width of the figure so it is more 
landscape-shaped (width > height) using options at the start of the chunk.

Rotating a figure is something LaTeX needs to do:  you would tell Sweave 
to produce the figure but not include it, then use \includegraphics{} 
with the right option to rotate it.

For example:

<<Myfig, fig=TRUE, include=FALSE, width=7in, height=4in>>=
plot(rnorm(100))
@

\includegraphics[angle=90,width=0.8\textheight]{Myfig}

This is untested, and you'll need to consult a LaTeX reference for 
rotating the figure caption, etc.

Duncan Murdoch



More information about the R-help mailing list