Skip to contents

The light colour scales use Okabe-Ito, the Viridis HCL approximation and Blue-Red 3. In dark mode the black category changes to light grey. The sequential palette uses the brighter section of Viridis, and the diverging palette uses Blue-Red 2. Set the same mode on the theme and scale. Use fixed scale limits with original category IDs to keep a cross-plot key. A label change then retains the category's position and colour.

Usage

forma_palette(
  n,
  type = c("discrete", "sequential", "diverging"),
  reverse = FALSE,
  mode = c("light", "dark"),
  medium = c("colour", "greyscale")
)

scale_colour_forma(
  type = c("discrete", "sequential", "diverging"),
  ...,
  reverse = FALSE,
  midpoint = 0,
  mode = c("light", "dark"),
  medium = c("colour", "greyscale")
)

scale_fill_forma(
  type = c("discrete", "sequential", "diverging"),
  ...,
  reverse = FALSE,
  midpoint = 0,
  mode = c("light", "dark"),
  medium = c("colour", "greyscale")
)

Arguments

n

Number of colours. Discrete values may not exceed palette capacity.

type

Discrete, sequential or diverging.

reverse

Reverse palette order.

mode

Intended light or dark background.

medium

Colour output or greyscale reproduction.

...

Arguments to the corresponding ggplot2 scale.

midpoint

Value at the neutral colour of a diverging scale.

Value

A character vector from forma_palette(), or a ggplot2 scale.

Details

The five-category greyscale uses alternating lightness. Ordered print scales encode magnitude with lightness. On a signed greyscale the labelled midpoint separates the two signs. A legend, text or line pattern can help distinguish values when colours or shades appear similar. Mosaic residual shading and its model-specific breaks are configured with ggmosaic().

Examples

forma_palette(4)
#> [1] "#000000" "#E69F00" "#56B4E9" "#009E73"
ggplot2::ggplot(iris, ggplot2::aes(Sepal.Length, Petal.Length, colour = Species)) +
  ggplot2::geom_point() + scale_colour_forma()

ggplot2::ggplot(iris, ggplot2::aes(Species, fill = Species)) +
  ggplot2::geom_bar() + scale_fill_forma()