gradient: Generate Gradient from Continuous Variable

Description Usage Arguments See Also Examples

View source: R/misc.R

Description

Assign colors based on a continuous variable. Useful for plotting functions where you would like to generate a gradient based on (a function of) the continuous variables you are plotting quickly.

Usage

1
gradient(x, m = 10, cols = c("darkorange", "grey60", "darkblue"))

Arguments

x

a continuous variable to generate colors over.

m

the number of distinct colors you wish to pull from the pallete.

cols

the colors to interpolate over. passed to colorRampPalette.

See Also

colorRampPalette

Examples

1
2
dat <- data.frame(y=rnorm(100), x=rnorm(100))
with( dat, plot( y ~ x, col=gradient(y) ) )

Kmisc documentation built on May 29, 2017, 1:43 p.m.

Related to gradient in Kmisc...