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", ...)

Arguments

x

A ggplot2 layer object, a ggplot, a grob, or a character string naming a filter

max_colours

The maximum number of colours to use. The result may contain fewer colours but never more.

colourspace

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.

Value

Depending on the input, either a grob, Layer, list of Layers, guide, or element object. Assume the output can be used in the same context as the input.

See also

Other dithering filters: with_circle_dither()

Examples

library(ggplot2)
ggplot(faithfuld, aes(waiting, eruptions)) +
  with_dither(
    geom_raster(aes(fill = density), interpolate = TRUE),
    max_colours = 10
  ) +
  scale_fill_continuous(type = 'viridis')