get_col_palette: Get color palette in the form of colorRampPalette functions.

View source: R/colors.R

get_col_paletteR Documentation

Get color palette in the form of colorRampPalette functions.

Description

Get color palette in the form of colorRampPalette color interpolation functions. Use with get_col_gradient() or get_element_colors() from this package.

Usage

get_col_palette(brew_pal = NA, custom = NA, rev = F)

Arguments

brew_pal

character string or NA. Exact name of RColorBrewer palette. e.g. "RdBu".

custom

Na or character vector with colors specifying palette order. e.g. c("red", "white", "blue"). Any hex codes or R colors (see colors()) can be used.

rev

logical; should the brew_pal color palette order be reversed?

Details

Only one of the parameters (brew_pal or custom) must be specified (not NA), otherwise function will use custom only.

Value

A colorRampPalette color interpolation functions.

The two lines of code below are equivalent

get_col_palette(brew_pal = "RdBu") colorRampPalette(RColorBrewer::brewer.pal(9, "RdBu")) #' # Reverse the palette (i.e. blue to red) get_col_palette(brew_pal = "RdBu", rev = T)

get_col_palette(custom = c("forestgreen", "darkorchid4")) colorRampPalette(c("forestgreen", "darkorchid4"))

See Also

colorRampPalette function from grDevices. See ?colorRampPalette.


kazeera/hourglass documentation built on April 5, 2025, 7:18 a.m.