Re: [Rd] Sweave support added to rgl package

From: Dominick Samperi <>
Date: Wed, 20 Apr 2011 13:52:06 -0400

On Tue, Apr 19, 2011 at 2:18 PM, Duncan Murdoch <> wrote:
> I have just committed some code to the rgl package on
> to allow rgl images to be
> inserted into Sweave documents.  (This is not in the CRAN version yet.)  It
> makes use of the custom graphics driver support added by Brian Ripley.
> In R-devel (which will become R 2.14.0 next spring in New Zealand, next fall
> in most other places), usage is quite straightforward.  For
> example, code like this in a Sweave document:
> <<fig=true, grdevice=rgl.Sweave, pdf=false, stayopen=TRUE>>=
> x <- rnorm(100); y <- rnorm(100); z <- rnorm(100)
> plot3d(x, y, z)
> @
> will insert a .png snapshot of the figure.  Because that chunk has
> "stayopen=TRUE", it can be followed by another chunk to add
> to the figure, e.g.
> <<fig=true, grdevice=rgl.Sweave, pdf=false>>=
> lines3d(x[1:10], y[1:10], z[1:10], col="red")
> @
> All of this is possible in R 2.13.0, but it takes more work:  see the
> ?rgl.Sweave help page.
> I will eventually add postscript and PDF output options as well, and perhaps
> some support for the LaTeX movie15 package, but those are not there yet.
>  Comments or bug reports are welcome.
> Duncan Murdoch

I inserted your example into testrgl.Rnw under R 2.13.0, with Sweave.snapshot() at the end of both chunks, but things did not work as expected.

I used:
$ R CMD Sweave testrgl.Rnw
$ pdflatex tesetrgl
(view testrgl.pdf)

When R CMD Sweave is run the graphics is displayed interactively.

There is no graphics in the PDF file, even though both .png files are read when pdflatex is run.

Dominick mailing list Received on Wed 20 Apr 2011 - 17:55:09 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 Wed 20 Apr 2011 - 18:40:48 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive