Skip to contents

Returns a vector of colors drawn from one of the palettes in EraPalettes. Supports both discrete (curated subsets) and continuous (interpolated) palettes.

Usage

era.brewer(
  palette_name,
  n,
  type = c("discrete", "continuous"),
  direction = c(1, -1),
  override_order = FALSE,
  return_hex = FALSE
)

Arguments

palette_name

Character. Name of the palette; must be one of names(EraPalettes).

n

Integer. Number of colors to return. Defaults to the full palette length.

type

One of "discrete" or "continuous". If omitted, chosen automatically: "continuous" when n exceeds the palette length, otherwise "discrete".

direction

1 for the standard order, -1 for reversed.

override_order

Logical. If TRUE, return colors in their stored order rather than the curated order-of-use for the requested n.

return_hex

Logical. If TRUE, also prints the hex codes.

Value

An object of class "palette": a character vector of hex codes with the palette name stored as an attribute.

Examples

# Discrete palette using the curated order-of-use
print(era.brewer("Lover2", n = 3))


# Continuous interpolation when n exceeds the stored palette length
print(era.brewer("Showgirl2", n = 50, type = "continuous"))


# Reverse direction
print(era.brewer("Fearless", direction = -1))


# Plug into a ggplot2 manual scale
library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point() +
  scale_color_manual(values = era.brewer("Lover2", n = 3))