Skip to contents

Convert percentiles to colors for maps, heatmap text, or barplots

Usage

calc_ejscreen_map_color(
  x,
  colorbins = ejscreen_color_defaults("ejscreen")$colorbins,
  colorfills = ejscreen_color_defaults("ejscreen")$colorfills
)

Arguments

x

Numeric vector of percentiles on a 0-100 scale.

colorbins

Strictly increasing interior cutoffs, excluding 0 and 100.

colorfills

Vector of colors of length length(colorbins) + 1.

Value

Character vector of colors, as long as x. Missing and out-of-range percentiles return NA_character_.

Examples

percentile <- c(-1, 0.50, 78, 80, 81, 91, 96, 100, 200)
EJAM:::calc_ejscreen_map_color(percentile)
EJAM:::pctile2color(percentile)
EJAM:::pctile2colorhex(percentile[percentile >= 0 & percentile <= 100])
EJAM:::ratio2color(c(-1, 0.5, 1, 1.06, 2, 2.5, 3, 4, 5, 200))