palette: Create a DJPR-appropriate palette for your ggplot2 chart

djpr_palR Documentation

Create a DJPR-appropriate palette for your ggplot2 chart

Description

Create a DJPR-appropriate palette for your ggplot2 chart

Usage

djpr_pal(n = 0, reverse = FALSE)

djpr_colour_manual(n, reverse = FALSE, ...)

djpr_fill_manual(n, reverse = 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.

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.

...

Arguments passed to ⁠ggplot2::scale_*_manual()⁠

Examples

library(ggplot2)

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

p

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

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

p


# When applying colours as a fill, use djpr_fill_manual, which is
# a wrapper around scale_colour_manual:

p <- ggplot(mtcars, aes(x = mpg, fill = factor(cyl))) +
  geom_histogram() +
  theme_djpr() +
  djpr_fill_manual(3)
p

djpr-data/djprtheme documentation built on April 15, 2023, 2:47 a.m.