Giter Club home page Giter Club logo

rasterpdf's Introduction

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.

rasterpdf's People

Contributors

ilarischeinin avatar trevorld avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

rasterpdf's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.