Learn R Programming

Kmisc (version 0.2.0)

kColor: Generate Gradient from Continuous Variable

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

kColor(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

Run this code
dat <- data.frame(y=rnorm(100), x=rnorm(100))
with( dat, plot( y ~ x, col=kColor(y) ) )

Run the code above in your browser using DataLab