Git Product home page Git Product logo

ggrastr's Introduction

<VPetukhov> CRAN status CRAN downloads

ggrastr

Rasterize only specific layers of a ggplot2 plot (for instance, large scatter plots with many points) while keeping all labels and text in vector format. This allows users to keep plots within a reasonable size limit without losing the vector properties of scale-sensitive information.

Installation

To install the stable version from CRAN, use:

install.packages('ggrastr')

To install the latest version, use:

install.packages('devtools')
devtools::install_github('VPetukhov/ggrastr', build_vignettes = TRUE)

Rasterize any ggplot2 layer

Note that with ggrastr version 0.2.0, any ggplot2 geom provided by the user can be rasterized with the function rasterise(). Furthermore, when the aspect ratio is distorted, points are rendered without distortion.

For more details and examples, see the vignettes:

Geoms provided

We also provide wrappers for several geoms to guarantee compatibility with an older version of ggrastr. However, we encourage users to use the rasterise() function instead.

  • geom_point_rast: raster scatter plots
  • geom_jitter_rast: raster jittered scatter plots
  • geom_boxplot_jitter: boxplots that allows to jitter and rasterize outlier points
  • geom_tile_rast: raster heatmap
  • geom_beeswarm_rast: raster bee swarm plots
  • geom_quasirandom_rast: raster quasirandom scatter plot

Troubleshooting

If your R session crashes when you try to render a rasterized plot, it's probably the case that your version of Cairo was built for another version of R (see Upgrading to a new version of R). To check if you are using a proper version, run the command below and ensure that the "Built" version is the same as your R version.

pkgs <- as.data.frame(installed.packages(), stringsAsFactors = FALSE, row.names = FALSE)
pkgs[pkgs$Package == 'Cairo', c("Package", "LibPath", "Version", "Built")]

To ensure that Cairo works, try running Cairo::Cairo(type='raster'); dev.off() and check if it crashes your R session.

Citation

If you find ggrastr useful for your publication, please cite:

Viktor Petukhov, Teun van den Brand and Evan Biederstedt (2021).
ggrastr: Raster Layers for 'ggplot2'. R package version 1.0.2.
https://CRAN.R-project.org/package=ggrastr

ggrastr's People

Contributors

evanbiederstedt avatar vpetukhov avatar teunbrand avatar bjreisman avatar jan-glx avatar kpjonsson avatar jsta avatar

Watchers

 avatar

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.