Convert values to colors along a color ramp

values_to_colors(
  x,
  min_val = NULL,
  max_val = NULL,
  colorset = c("darkblue", "dodgerblue", "gray80", "orange", "orangered"),
  missing_color = "black"
)

Arguments

x

a numeric vector to be converted to colors

min_val

a number that's used to set the low end of the color scale (default = 0)

max_val

a number that's used to set the high end of the color scale. If NULL (default), use the highest value in x

colorset

a set of colors to interpolate between using colorRampPalette (default = c("darkblue","dodgerblue","gray80","orangered","red"))

missing_color

a color to use for missing (NA) values.

Value

a character vector of hex color values generated by colorRampPalette. Color values will remain in the same order as x.