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

gradient

Create a matrix from vector to represent colors in gradient


Description

Create a matrix from vector to represent colors in gradient

Usage

gradient(x, min.color, max.color, alpha = NULL, use.names = TRUE, na.rm = TRUE)

Arguments

x

a numeric vector.

min.color

color of minimum value.

max.color

color of maximum value.

alpha

logical of whether to include alpha channel. NULL to let the function decide by input.

use.names

logical of whether to preserve names of input vector.

na.rm

logical indicating whether to ignore missing values as x is normalized. (defult is TRUE)

Value

a matrix with rgba columns in which each row corresponds to the rgba value (0-255) of each element in input vector x. Use csscolor to convert the matrix to css color strings compatible with web browsers.

See Also

Examples

gradient(c(1,2,3,4,5), "white", "red")
gradient(c(5,4,3,2,1), "white", "red")
gradient(c(1,3,2,4,5), "white", "red")
gradient(c(1,3,2,4,5), rgb(0,0,0,0.5), rgb(0,0,0,1), alpha = TRUE)

formattable

Create 'Formattable' Data Structures

v0.2.1
MIT + file LICENSE
Authors
Kun Ren [aut, cre], Kenton Russell [aut]
Initial release
2021-01-05

We don't support your browser anymore

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