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

col2value

Transform back from colors to values


Description

Transform back from colors to values

Usage

col2value(r, g, b, col_fun)

Arguments

r

red channel in sRGB color space, value should be between 0 and 1. The r, g and b argumentc can be wrapped into one variable which is either a three-column matrix or a vector of colors.

g

green channel in sRGB color space, value should be between 0 and 1.

b

blue channel in sRGB color space, value should be between 0 and 1.

col_fun

the color mapping function generated by colorRamp2.

Details

colorRamp2 transforms values to colors and this function does the reversed job. Note for some color spaces, it cannot transform back to the original value perfectly.

Value

A vector of original numeric values.

Author(s)

Zuguang Gu <z.gu@dkfz.de>

Examples

x = seq(0, 1, length = 11)
col_fun = colorRamp2(c(0, 0.5, 1), c("blue", "white", "red"))
col = col_fun(x)
col2value(col, col_fun = col_fun)
col2value("red", col_fun = col_fun)

col_fun = colorRamp2(c(0, 0.5, 1), c("blue", "white", "red"), space = "sRGB")
col = col_fun(x)
col2value(col, col_fun = col_fun)

circlize

Circular Visualization

v0.4.12
MIT + file LICENSE
Authors
Zuguang Gu
Initial release
2021-1-8

We don't support your browser anymore

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