rasterize | R Documentation |
Rasterise ggplot layers Takes a ggplot object or a layer as input and renders their graphical output as a raster.
rasterize(input, ...)
input |
ggplot plot object to rasterize |
... |
ignored |
The default dpi
(NULL
(i.e. let the device decide)) can conveniently be controlled by setting the option "ggrastr.default.dpi"
(e.g. options("ggrastr.default.dpi" = 30)
for drafting).
A modified Layer
object.
Teun van den Brand <t.vd.brand@nki.nl>
require(ggplot2)
# `rasterise()` is used to wrap layers
ggplot(pressure, aes(temperature, pressure)) +
rasterise(geom_line())
# The `dpi` argument controls resolution
ggplot(faithful, aes(eruptions, waiting)) +
rasterise(geom_point(), dpi = 5)
# The `dev` argument offers a few options for devices
require(ragg)
ggplot(diamonds, aes(carat, depth, z = price)) +
rasterise(stat_summary_hex(), dev = "ragg")
# The `scale` argument allows you to render a 'big' plot in small window, or vice versa.
ggplot(faithful, aes(eruptions, waiting)) +
rasterise(geom_point(), scale = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.