Learn R Programming

tagcloud (version 0.1)

smoothPalette: 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, na.color = "white")

Arguments

Value

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

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.

See Also

tagcloud

Examples

Run this code
smoothPalette( 1:3 )
# will print:
# "#FFFFFF" "#717171" "#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 )

Run the code above in your browser using DataLab