brewcol: Assign Colors to Collection of Values Using Color Brewer

Description Usage Arguments Value Examples

View source: R/brewcol.R

Description

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

Usage

1
2
3
4
5
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

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

JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.