R/scale2palette.R

#' scale2palette
#'
#' Extracts color values from a ggplot2 scale
#'
#' @param scale a ggplot2 scale object
#'
#' @return character
#'
#' @note Used by [scale_sepia_fill()] and [scale_sepia_color()]
#'
#' @export
scale2palette <- function (scale) {
  pal <- scale$palette
  function (n) {
    swatches <- pal(seq(0, 1, length.out = n))
    return(swatches)
  }
}
BAAQMD/ggtools documentation built on Feb. 8, 2023, 6:22 p.m.