Skip to contents

Color gradient for continuous variable

Usage

colorgradient.x(
  x,
  symmetric = FALSE,
  lo_col = "#0290EE",
  mid_col = "#1A1A1A",
  hi_col = "#FFBD4F",
  space = "Lab"
)

Arguments

x

Float, vector

symmetric

Logical: If TRUE, make symmetric gradient between -max(abs(x)) and max(abs(x))

lo_col

Low color

mid_col

Middle color

hi_col

High color

space

Character: "rgb" or "Lab".

Author

EDG

Examples

if (FALSE) { # \dontrun{
x <- seq(-10, 10, length.out = 51)
previewcolor(colorgradient.x(x))
x <- sort(rnorm(40))
previewcolor(colorgradient.x(x, mid_col = "white"))
# Notice how most values are near zero therefore almost white
} # }