get_palette: Known palettes

View source: R/palette-registry.R

get_paletteR Documentation

Known palettes

Description

The scales packages keeps track of a set of palettes it considers 'known'. The benefit of a known palette is that it can be called by name in functions as as_continuous_pal() or as_discrete_pal().

Usage

get_palette(name, ...)

set_palette(name, palette, warn_conflict = TRUE)

palette_names()

reset_palettes()

Arguments

name

A string giving the palette name.

...

Additional arguments to pass to palette when it is a function but not a palette class function.

palette

A palette, function or character vector.

warn_conflict

A boolean which if TRUE (default), warns when replacing a known palette.

Value

The get_palette() function returns a palette. The set_palette() function is called for side effects and returns nothing.

Examples

# Get one of the known palettes
get_palette("hue")

# Set a new custom palette
cols <- c("palegreen", "deepskyblue", "magenta")
set_palette("aurora", palette = cols)

# Palette is now known
"aurora" %in% palette_names()
as_continuous_pal("aurora")

# Resetting palettes
reset_palettes()

r-lib/scales documentation built on Nov. 2, 2024, 9:31 a.m.