brewPalCont: Brew a color palette from a numerical vector x with optional...

Description Usage Arguments Value Examples

Description

Uses RColorBrewer palette names, default is OrRd with 9 colors Use more/less colors (n) for a bigger/smaller range, i.e. more/less extremes at each end. Use more/less digits for more/less categories of colors. If namesFrom given, add names to colors; otherwise, add names(x) or x.

Usage

1
2
3
4
5
6
7
8
9
brewPalCont(
  x,
  n = 5,
  name = "YlGn",
  digits = 2,
  namesFrom = NULL,
  NAcolor = "#000000",
  rev = TRUE
)

Arguments

x

Numeric vector with optional names.

n

Number of colors for RColorBrewer (depends on the name). Default 5 is max for printer-friendly.

name

Name of the RColorBrewer palette. Default YlGn is printer-friendly.

digits

Number of digits in x to form categories for colors. May be negative to round to tens, hundreds, etc.

namesFrom

Vector of names to be added to colors; default is names(x) or x.

NAcolor

Color for NA values, default black #000000

rev

Revert colors, e.g. Rd to Or instead of Or to Rd; default TRUE

Value

Named vector of colors of the same length as x.

Examples

1
2
3
4
5
6
7
brewPalCont(10:20)
brewPalCont(10:20, digits=-1)
brewPalCont(10:20, n=3, digits=-1)
brewPalCont(c(18,12,14,16,20,11,10,17,13,19,15), n=3, digits=-1)[as.character(10:20)]
brewPalCont(c(10:14, 0,  16:20), n=3, digits=-1)
brewPalCont(c(10:14, NA, 16:20), n=3, digits=-1)
brewPalCont(c(10:14, NA, 16:20), n=3, digits=-1, rev=FALSE)

peterjuv/myHelpers documentation built on June 12, 2021, 1:44 p.m.