brewcol: Assign Colors to Collection of Values Using Color Brewer

View source: R/brewcol.R

brewcolR Documentation

Assign Colors to Collection of Values Using Color Brewer

Description

Assign a specified number of Color Brewer colors to a collection of values.

Usage

brewcol(
  x,
  n = 9,
  name = c("YlGnBu", "Oranges", "Greens", "Blues", "Greys", "Dark2")[1]
)

Arguments

x

A numeric vector of values to which colors will be assigned.

n

An integer scalar indicating the number of unique colors to be assigned, default 9. The range of possible values depends on the palette named, typically n should be from 3 to 9.

name

A character scalar indicating the palette name to be passed to brewer.pal, default "YlGnBu".

Value

A character vector of colors expressed as hexadecimal values with a "#" prefix.

Examples

x <- 1:20
mycol <- brewcol(x, 4, "Dark2")
plot(x, x, col=mycol, pch=16, cex=3)

JVAdams/GLFC documentation built on Jan. 5, 2023, 12:59 a.m.