Skip to contents

This function interpolates a color between three specified colors (minimum, midpoint, and maximum) based on the position of a numeric value within a defined range.

Usage

getColor(val, min, mid, max, colormin, colormid, colormax)

Arguments

val

A numeric value to be mapped to a color.

min

The minimum value of the range.

mid

The midpoint value of the range.

max

The maximum value of the range.

colormin

The color (in HEX format) corresponding to the minimum value.

colormid

The color (in HEX format) corresponding to the midpoint value.

colormax

The color (in HEX format) corresponding to the maximum value.

Value

A HEX color string representing the interpolated color.

Examples

getColor(0.75, 0, 0.5, 1, "#0000FF", "#00FF00", "#FF0000")
#> [1] "#808000"