smoothPalette {tagcloud} | R Documentation |
Replace a vector of numbers by a gradient of colors
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
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 |
max |
Values of |
min |
Values of |
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
Examples
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 )