Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

color.gradient

Calculate an arbitrary sequence of colors


Description

color.gradient is now just a call to color.scale with a vector of equally spaced integers (1:nslices). The function is kept for backward compatibility.

Usage

color.gradient(reds,greens,blues,nslices=50)

Arguments

reds,greens,blues

vectors of the values of the color components as 0 to 1.

nslices

The number of color "slices".

Value

A vector of hexadecimal color values as used by col.

Note

The function is mainly useful for defining a set of colors to represent a known number of gradations. Such a set can be used to assign a grade to a small number of values (e.g. points on a scatterplot - but see color.scale for large numbers) and display a color bar using gradient.rect as a legend.

Author(s)

Jim Lemon

See Also

Examples

# try it with red and blue endpoints and green midpoints.
 color.gradient(c(0,1),c(1,0.6,0.4,0.3,0),c(0.1,0.6))

plotrix

Various Plotting Functions

v3.8-1
GPL (>= 2)
Authors
Jim Lemon, Ben Bolker, Sander Oom, Eduardo Klein, Barry Rowlingson, Hadley Wickham, Anupam Tyagi, Olivier Eterradossi, Gabor Grothendieck, Michael Toews, John Kane, Rolf Turner, Carl Witthoft, Julian Stander, Thomas Petzoldt, Remko Duursma, Elisa Biancotto, Ofir Levy, Christophe Dutang, Peter Solymos, Robby Engelmann, Michael Hecker, Felix Steinbeck, Hans Borchers, Henrik Singmann, Ted Toal, Derek Ogle, Darshan Baral, Ulrike Groemping, Bill Venables
Initial release
2021-01-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.