rasterpdf is an R package to plot raster graphics in PDF files. This can be
useful when one needs multipage documents, but the plots contain so many
individual elements that use of vector graphics (with
results in inconveniently large file sizes. Internally,
rasterpdf plots each
individual page as a PNG, and then combines them in one PDF file.
rasterpdf can be installed from
Or the development version from GitHub with:
rasterpdf's main function
raster_pdf() can be used as any graphics device
library(rasterpdf) raster_pdf("Rplots.pdf") plot(iris) image(volcano) plot(EuStockMarkets) dev.off()
Or similarly with
library(ggplot2) library(rasterpdf) raster_pdf("diamonds.pdf") ggplot(diamonds, aes(carat, price)) + geom_point() ggplot(diamonds, aes(carat, price, colour = color)) + geom_point() ggplot(diamonds, aes(carat, price, colour = clarity)) + geom_point() dev.off()
The output size and resolution can be set with parameters
res. The default is 7 x 7 inches and 72 ppi. Any other
...) are passed through to the PNG device function. By default
grDevices::png(), but another function can also be specified, such
ragg::agg_png(). The PDF file is by default generated with
grDevices::cairo_pdf() if cairo is available, and
otherwise. Here again it is also possible to specify another function.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.