As of R 2.13.0, it is possible to include
rgl graphics into
a Sweave document. These functions support that
Sweave.snapshot() rgl.Sweave(name, width, height, options, ...) rgl.Sweave.off()
- name, width, height, options, ...
These arguments are passed by
rgl.Sweavewhen it opens the device.
rgl.Sweave function is not normally called by the user. The user
specifies it as the graphics driver when opening the code chunk, e.g. by
<<fig = TRUE, pdf = FALSE, grdevice = rgl.Sweave, resolution = 100>>=
rgl device is closed at the end of the code chunk,
rgl.Sweave.off() will be called automatically. It
will save a snapshot
of the last image (by default in
.png format) for inclusion in the
Sweave document and (by default) close the device.
can be called to save the image before the end of the chunk. Only one
snapshot will be taken per chunk.
Several chunk options are used by the
rgldevice will not be closed at the end of the chunk, instead a call to
Sweave.snapshot()will be used if it has not been called explicitly. Subsequent chunks can add to the scene.
png). The output may be specified as
outputtype = pdfor
outputtype = epsinstead, in which case the
rgl.postscriptfunction will be used to write output in the specified format. Note that
rgl.postscripthas limitations and does not always render scenes correctly.
(default 0.1). After creating the display window,
Sys.sleepwill be called to delay this many seconds, to allow the display system to initialize. This is needed in X11 systems which open the display asynchronously. If the default time is too short,
rgl.Sweavemay falsely report that the window is too large to open.
These functions are called for their side effects.
rgl package relies on your graphics hardware to render OpenGL scenes,
and the default
.png output copies a bitmap from the hardware device. All
such devices have limitations on the size of the bitmap, but they do not
always signal these limitations in a way that
rgl will detect. If you find
that images are not being produced properly, try reducing the size using
height chunk options.
RweaveLatex for a description of alternate graphics drivers
in Sweave, and standard options that can be used in code chunks.