Creaetes a diverging color palette, typically used to display categories on a likert scale, from best to worst.
Usage
populace_pal_diverging(
palette = c("primary", "blue_green", "blue_red", "green_red"),
grey_pos = c("last", "middle", "first", "none"),
n = c(3, 5, 7, 9),
rev = FALSE
)
populace_pal(
palette = c("core", "neutrals", "vary", "names"),
order = switch(which(c("core", "neutrals", "vary", "names") %in% palette[1]),
list(1:10), list(1:3), list(1:13), list(1:13))
)Arguments
- palette
Which palette to use.
- grey_pos
Position of a gray color (typically used to display a
NoneorDon't Knowcategory.)- n
Number of categories your data has. Choose between
3,5,7,9colors (including grey).- rev
Logical. Should the vector of colors be reversed or not (default).
- order
The order of colours in the final palette in
populace_pal()
Examples
library(ggplot2)
library(scales)
library(dplyr)
# Primary
populace_pal_diverging(grey_pos = "last", n = 9) %>%
show_col()
# Green to Blue palette
populace_pal_diverging(
palette = "blue_green", grey_pos = "middle", n = 9
) %>%
show_col()
# Green to Red palette
populace_pal_diverging(palette = "blue_red", grey_pos = "middle", n = 9) %>%
show_col()
# Green to Red palette
populace_pal_diverging(palette = "green_red", grey_pos = "middle", n = 9) %>%
show_col()