Skip to contents

Creates a diverging color palette, typically used to display categories on a likert scale, from best to worst.

Usage

czi_pal_diverging(
  palette = c("primary", "teal_pink", "green_pink", "blue_green"),
  grey_pos = c("last", "middle", "first", "none"),
  n = c(3, 5, 7, 9),
  rev = FALSE
)

czi_pal(
  palette = c("core", "neutrals", "vary", "names"),
  order = switch(which(c("core", "neutrals", "vary", "names") %in% palette[1]),
    list(1:13), list(1:2), list(1:15), list(1:15))
)

Arguments

palette

Which palette to use.

grey_pos

Position of a gray color (typically used to display a None or Don't Know category.)

n

Number of categories your data has. Choose between 3, 5 , 7, 9 colors (including grey).

rev

Logical. Should the vector of colors be reversed or not (default).

order

The order of colours in the final palette in czi_pal()

Examples

library(ggplot2)
library(scales)
library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

# Primary
czi_pal_diverging(grey_pos = "last", n = 9) %>%
  show_col()


# Teal to Pink palette
czi_pal_diverging(palette = "teal_pink", grey_pos = "middle", n = 9) %>%
  show_col()


# Green to Pink palette
czi_pal_diverging(palette = "green_pink", grey_pos = "middle", n = 9) %>%
  show_col()

  
# Green to Blue palette
czi_pal_diverging(palette = "blue_green", grey_pos = "middle", n = 9) %>%
  show_col()