smoothPalette: Replace a vector of numbers by a gradient of colors

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Replace a vector of numbers by a vector of colors from a palette, such that values correspond to the colors on a smooth gradient.

Usage

1
2
smoothPalette(x, pal = NULL, max = NULL, min = NULL, n = 9,
  palfunc = NULL, na.color = "white")

Arguments

x

A numeric vector

pal

Character vector containing the color gradient onto which the numeric vector x will be mapped. By default, a gradient from white to black is generated. If it is a single character value, it will be treated as name of an RColorBrewer palette (see brewer.pal).

max

Values of x larger than max will be replaced by max

min

Values of x smaller than min will be replaced by min

n

Number of steps

palfunc

Palette function returned by colorRampPalette

na.color

NA values will be replaced by that color

Details

This function is used to map a continues numerical vector on an ordinal character vector, in especially a vector of colors. Color palette can be specified using an RColorBrewer palette name.

Value

A character vector of the same length as the numeric vector x, containing the matching colors.

Author(s)

January Weiner <january.weiner@gmail.com>

See Also

tagcloud

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
smoothPalette( 1:3 )
# will print:
# "#CCCCCC" "#666666" "#000000"

smoothPalette( 1:3, pal= "Blues" )
# will produce:
# "#F7FBFF" "#6BAED6" "#08306B"

x <- runif( 100 )
plot( 1:100, x, col= smoothPalette( x, pal= "BrBG" ), pch= 19 )

tagcloud documentation built on May 2, 2019, 5:02 a.m.