Skip to contents

Diverging colour palettes are used to encode numerical information that is ordered and has a meaningful midpoint and meaningful extreme values. For example, a five-point scale used to measure attitudes in a survey, from Strongly Agree to Strongly Disagree, with Neither Agree Nor Disagree, would require a diverging colour palette. Diverging palettes combine two different hues, with the highest chroma (the intensity of a colour) representing the extreme values, and the neutral midpoint value being the intersection of the two hues.

Usage

pal_diverging(
  palette = c("blue_green", "blue_yellow", "blue_red"),
  alpha = 1,
  reverse = FALSE
)

Arguments

palette

Currently there are two diverging colour palettes available: "blue_green" (a 9-colour blue-grey-green palette using NHS Blue, NHS Pale Grey, and NHS Aqua Green), blue_yellow_red (a 9-colour blue-yellow-red palette using NHS Blue and NHS Pale Grey), and blue_red (a 9-colour blue-to-red palette uses NHS Blue and NHS Pale Grey).

alpha

Transparency level, a real number in (0, 1]. See alpha in rgb for details.

reverse

The default, FALSE, generates the colour palette as defined, while TRUE generates the colour palette in reverse order.

Examples

scales::show_col(pal_diverging(palette = "blue_green")(9))

scales::show_col(pal_diverging(palette = "blue_yellow")(9))

scales::show_col(pal_diverging(palette = "blue_red")(9))

scales::show_col(pal_diverging(palette = "blue_yellow", alpha = 0.7)(9))

scales::show_col(pal_diverging(palette = "blue_red", reverse = TRUE)(9))