Re: [R] Sweave figure

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Wed, 09 Jul 2008 19:39:51 -0400

Georg Otto wrote:
> Hi,
>
> I have a problem using figures in Sweave:
>
> To save my figures, I use
>
> \SweaveOpts{prefix.string=figures/figure}
>
> I adjust the figure size for my pdf document using
>
> <<graphicsFun, fig=TRUE, echo=FALSE, height=10, width=5, eval=TRUE>>=
>
> this works fine. The file
>
> figures/figure-graphicsFun.pdf
>
>
> has the right size, and so has the figure in the final pdf
> document. The problem is, that during Sweave'ing, the plot is printed
> also to the active x11 device, which has default size settings. In
> some cases, this results in an error, because some parameters
> (e.g. margins) might not be compatible with the default size. I think
> the best solution would be to supress printing to the x11 device by
> that code chunk, since I do not really need this side effect, but I
> have not found how to do this and do not know if this is possible. Any
> hints?
You could use options(device= ...) early in your document to tell R to use a device other than X11 by default. If it was a pdf device with height and width matching the ones you give, you shouldn't get any spurious errors.

I'm not sure why Sweave produces default graphics output as well as pdf and eps; perhaps someone could comment on that (or say how to turn the default output off, if that's possible).

Duncan Murdoch



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 09 Jul 2008 - 23:47:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 10 Jul 2008 - 00:31:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive