Open a graphics device for raster PDF files. Internally, a PNG device is used for the individual pages, which are then combined into one PDF file.
raster_pdf(
filename = "Rplots.pdf",
width = NULL,
height = NULL,
units = NULL,
res = NULL,
png_function = NULL,
pdf_function = NULL,
...
)agg_pdf(...)
A character string of the output file name.
Page width. If NULL
, use value of
getOption("rasterpdf.width")
if set, and default to 7
otherwise.
Page height. If NULL
, use value of
getOption("rasterpdf.height")
if set, and default to 7
otherwise.
The units in which height
and weight
are given. Can be
"in"
(inches), "cm"
, "mm"
, or "px"
(pixels). If NULL
, use
value of getOption("rasterpdf.units")
if set, and default to "in"
` otherwise.
Resolution in ppi. If NULL
, use value of
getOption("rasterpdf.res")
if set, and default to 72L
otherwise.
A PNG device function. If NULL
, use grDevices::png()
.
A PDF device function. If NULL
, use
grDevices::cairo_pdf()
if it is available, and grDevices::png()
otherwise.
Further arguments passed through to the PNG device function
specified in png_function
.
The ability to plot raster graphics in PDF files can be useful when one needs
multipage documents, but the plots contain so many individual elements that
use of vector graphics (with grDevices::pdf()
) results in inconveniently
large file sizes
Internally, the function plots each individual page in a PNG file, which are
then combined into one PDF file when dev.off()
is called. By default, the
PNGs are generated with grDevices::png()
, but another device function can
also be specified. The PDF is by default generated with
grDevices::cairo_pdf()
if it is available, and
grDevices::pdf()
otherwise. Again, it is possible to specify another PDF
device function.
agg_pdf(...)
is shorthand for
raster_pdf(..., png_function = ragg::agg_png)
.
grDevices::pdf()
, grDevices::cairo_pdf()
,
grDevices::png()
, ragg::agg_png()
# NOT RUN {
raster_pdf(tempfile(fileext = ".pdf"))
plot(iris)
dev.off()
# }
Run the code above in your browser using DataLab