Generate Color Mapping Functions

A color mapping is generated according to the break values and corresponding colors. Other colors are generated by interpolating in a certain color space. The functions were part of the 'circlize' package < https://CRAN.R-project.org/package=circlize>.


colorRamp2: Generate Color Mapping Functions

Install

The package can be installed from CRAN:

install.packages("colorRamp2")

or directly from GitHub:

devtools::install_github("jokergoo/colorRamp2")

Usage

The colorRamp2() function can generate a color mapping function from a vector of break values and a vector of corresponding colors. Other colors are linearly interpolated in a certain color space.

library(colorRamp2)

col_fun = colorRamp2(c(0, 0.5, 1), c("blue", "white", "red"))
col_fun(seq(0, 1, length = 20))
##  [1] "#0000FFFF" "#522CFFFF" "#7448FFFF" "#8E61FFFF" "#A479FFFF" "#B891FFFF"
##  [7] "#C9A9FFFF" "#DAC1FFFF" "#E9DAFFFF" "#F8F3FFFF" "#FFF5F1FF" "#FFE1D6FF"
## [13] "#FFCDBBFF" "#FFB8A1FF" "#FFA388FF" "#FF8E6EFF" "#FF7756FF" "#FF5E3DFF"
## [19] "#FF3F23FF" "#FF0000FF"
plot(NULL, xlim = c(0, 1), ylim = c(0, 1))
x = seq(0, 1, length = 20)
y = rep(0.5, 20)
points(x, y, pch = 16, col = col_fun(x), cex = 2)

image

License

MIT @ Zuguang Gu

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("colorRamp2")

0.1.1 by Zuguang Gu, 6 months ago


https://github.com/jokergoo/colorRamp2


Browse source code at https://github.com/cran/colorRamp2


Authors: Zuguang Gu [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports colorspace, grDevices, methods, stats

Suggests knitr


Imported by sfcurve, turkeyelections.


See at CRAN