Skip to contents

Maps data values to fill colours. Same semantics as scale_color() but for the fill aesthetic (bars, boxes, polygons, etc.).

Usage

scale_fill(
  plot,
  name = ggplot2::waiver(),
  trans = NULL,
  limits = NULL,
  range = NULL,
  breaks = NULL,
  labels = NULL,
  ...
)

Arguments

plot

A plotit object.

name

Scale title (legend name). ggplot2::waiver() = use variable name.

trans

Scale transformation. NULL auto-detects, otherwise one of: "identity", "discrete", "reverse", "binned". Unsupported values (e.g. "log") produce a targeted error message.

limits

Data domain.

range

Output range. Same as scale_color(): colour vector, or "viridis", "brewer", "grey", "hue".

breaks

Legend key positions.

labels

Legend key labels.

...

Passed to the underlying ggplot2 scale function.

Value

A modified plotit object.

Examples

plotit(iris, encode(x = Species, fill = Species)) |>
  mark_bar() |>
  scale_fill(range = "viridis")