This filter reduces the number of colours in your layer and uses the Floyd-Steinberg algorithm to even out the error introduced by the colour reduction.
with_dither(x, max_colours = 256, colourspace = "sRGB", ...)
A ggplot2 layer object, a ggplot, a grob, or a character string naming a filter
The maximum number of colours to use. The result may contain fewer colours but never more.
In which colourspace should the dithering be calculated
Arguments to be passed on to methods. See the documentation of supported object for a description of object specific arguments.
Depending on the input, either a grob
, Layer
, list of Layer
s,
guide
, or element
object. Assume the output can be used in the same
context as the input.
Other dithering filters:
with_circle_dither()
library(ggplot2)
ggplot(faithfuld, aes(waiting, eruptions)) +
with_dither(
geom_raster(aes(fill = density), interpolate = TRUE),
max_colours = 10
) +
scale_fill_continuous(type = 'viridis')