grattan_pal: Create a Grattan-appropriate palette for your chart.

View source: R/grattan_pal.R

grattan_palR Documentation

Create a Grattan-appropriate palette for your chart.

Description

Create a Grattan-appropriate palette for your chart.

Usage

grattan_pal(n = 0, reverse = FALSE, faded_level = 0, faded = FALSE)

Arguments

n

Numeric. The number of levels in your colour scale. Minimum value is 1, maximum is 10. Using more than 6 is not recommended. If you don't specify 'n', a five-colour palette will be used, which may not look right. Specify 'n'.

By default, n = 2 will give you light orange and dark orange. Use n = "2a" if you want light orange and red.

reverse

Logical. FALSE by default. Setting to TRUE reverses the standard colour order. Standard colour order runs from light to dark. If you set reverse to TRUE, colours will run from dark to light.

faded_level

Integer between 0 (no fade; the default) and 8 (most faded).

faded

Deprecated - use faded_level. Logical. FALSE by default. Setting to TRUE returns the faded variations of the standard colours. If TRUE and faded_level = 0, sets faded_level to 5.

Examples

library(ggplot2)

p <- ggplot(mtcars, aes(x = wt, y = mpg, col = factor(cyl))) +
    geom_point() +
    theme_grattan() +
    scale_colour_manual(values = grattan_pal(n = 3))

p

# Alternatively, use grattan_colour_manual(), which is a wrapper
# around scale_colour_manual():

p <- ggplot(mtcars, aes(x = wt, y = mpg, col = factor(cyl))) +
    geom_point() +
    theme_grattan() +
    grattan_colour_manual(n = 3)

p


MattCowgill/grattantheme documentation built on Jan. 13, 2023, 11:02 a.m.