djpr_pal | R Documentation |
Create a DJPR-appropriate palette for your ggplot2 chart
djpr_pal(n = 0, reverse = FALSE)
djpr_colour_manual(n, reverse = FALSE, ...)
djpr_fill_manual(n, reverse = FALSE, ...)
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 |
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 |
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.