Creaetes a diverging color palette, typically used to display categories on a likert , from best to worst.
Usage
g6tr_pal_diverging(
palette = c("green_blue", "green_red", "yellow_red", "blue_red"),
grey_pos = c("last", "middle", "first", "none"),
n = c(3, 5, 7, 9),
rev = FALSE
)
g6tr_pal(
palette = c("core", "neutrals", "vary", "names"),
order = switch(which(c("core", "neutrals", "vary", "names") %in% palette[1]),
list(1:8), list(1:7), list(1:13), list(1:13))
)Arguments
- palette
Color 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
g6tr_pal()
Examples
library(ggplot2)
library(scales)
library(dplyr)
# Green to Blue palette
g6tr_pal_diverging(palette = "green_blue", grey_pos = "middle", n = 9) %>%
show_col()
# Green to Red palette
g6tr_pal_diverging(palette = "green_red", grey_pos = "middle", n = 9) %>%
show_col()
# Yellow to Red palette
g6tr_pal_diverging(palette = "yellow_red", grey_pos = "middle", n = 9) %>%
show_col()