R/pal-manual.R

Defines functions pal_manual

Documented in pal_manual

#' Manual palette (discrete)
#'
#' @param values vector of values to be used as a palette.
#' @export
pal_manual <- function(values) {
  force(values)
  function(n) {
    n_values <- length(values)
    if (n > n_values) {
      cli::cli_warn("This manual palette can handle a maximum of {n_values} values. You have supplied {n}")
    }
    unname(values[seq_len(n)])
  }
}

#' @export
#' @rdname pal_manual
manual_pal <- pal_manual

Try the scales package in your browser

Any scripts or data that you put into this service are public.

scales documentation built on July 4, 2024, 1:11 a.m.