gradient.color.scale {smacpod}R Documentation

Create gradient color scale with midpoint

Description

Create gradient color scale with midpoint

Usage

gradient.color.scale(
  minval,
  maxval,
  n = 11,
  low = "blue",
  mid = "white",
  high = "red",
  midpoint = 0,
  ...
)

Arguments

minval

The minimum value of the data to be colored

maxval

The maximum value of the data to be colored

n

The desired number of breaks (approximately)

low

The color for the low values

mid

The color used for the midpoint of the gradient

high

The color used for the high values

midpoint

The midpoint of the color scale

...

Arguments passed on to grDevices::colorRamp

colors

colors to interpolate; must be a valid argument to col2rgb().

bias

a positive number. Higher values give more widely spaced colors at the high end.

space

a character string; interpolation in RGB or CIE Lab color spaces.

interpolate

use spline or linear interpolation.

alpha

logical: should alpha channel (opacity) values be returned? It is an error to give a true value if space is specified.

Value

A list with col and breaks components specifying the colors and breaks of the color scale.

References

Based on code from https://stackoverflow.com/a/10986203/5931362

Examples

data(grave)
lr = logrr(grave)
grad = gradient.color.scale(min(lr$v, na.rm = TRUE), max(lr$v, na.rm = TRUE))
plot(lr, col = grad$col, breaks = grad$breaks)

[Package smacpod version 2.6 Index]