MyNixOS website logo
Description

Plot Raster Graphics in PDF Files.

The ability to plot raster graphics in PDF files can be useful when one needs multi-page documents, but the plots contain so many individual elements that (the usual) use of vector graphics results in inconveniently large file sizes. Internally, the package plots each individual page as a PNG, and then combines them in one PDF file.

rasterpdf

Lifecycle: experimental CRAN status Travis build status Codecov test coverage License: MIT

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 grDevices::pdf()) results in inconveniently large file sizes. Internally, rasterpdf plots each individual page as a PNG, and then combines them in one PDF file.

Installation

rasterpdf can be installed from CRAN with:

install.packages("rasterpdf")

Or the development version from GitHub with:

devtools::install_github("ilarischeinin/rasterpdf")

Usage

rasterpdf's main function raster_pdf() can be used as any graphics device in R:

library(rasterpdf)

raster_pdf("Rplots.pdf")
plot(iris)
image(volcano)
plot(EuStockMarkets)
dev.off()

Or similarly with ggplot2:

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 width, height, units, and res. The default is 7 x 7 inches and 72 ppi. Any other parameters (...) are passed through to the PNG device function. By default this is 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 grDevices::pdf() otherwise. Here again it is also possible to specify another function.

Metadata

Version

0.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows