Learn R Programming

fifer (version 1.1)

gradient.legend: Create a gradiented legend

Description

Create a gradiented legend

Usage

gradient.legend(y = NULL, yrange = NULL, cols = c("red", "blue"),
  location = c(0.075, 0.3, 0.575, 0.975), n = 100, ...)

Arguments

y
the variable used to create the gradient, typically in number.to.colors
yrange
The range of y values. If y is supplied, it will pulls these from the actual y values.
cols
The color gradients to be used that are passed to colorRampPalette.
location
The location of the subplot, expressed in fractions of the entire plot (left x, right x, bottom y, top y).
n
the number of values used for the gradient. Higher numbers make a higher resolution
...
other arguments passed to image

See Also

number.to.colors colorRampPalette

Examples

Run this code
y = rnorm(100); x = .6*y + rnorm(100,0,sqrt(1-.6^2))
randnum = runif(100)
plot(x,y, col=number.to.colors(randnum), pch=16)
gradient.legend(randnum, xlab="", ylab="")

Run the code above in your browser using DataLab