createColorScale: Create a function defining a color scale

View source: R/createColorScale.R

createColorScaleR Documentation

Create a function defining a color scale

Description

Creates a function defining a color scale. The resulting function (e.g., 'scale') is used as
clr <- scale(x,mn=sclMin,mx=sclMax,alpha=alpha)
to return a color based on the color associated with value x (scaled into the interval sclMin to sclMax) in the defined color scale, with transparency 'alpha'.

Usage

createColorScale(
  clrs = c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#FF7F00", "red",
    "#7F0000"),
  name = NULL,
  bias = 1,
  space = c("rgb", "Lab"),
  interpolate = c("linear", "spline"),
  showAsWheel = FALSE,
  showAsBar = FALSE
)

Arguments

clrs
  • vector of colors defining the base scale (ignored if 'name' is given)

name
  • name of base color scale (pre-defined: 'jet', 'coldhot', 'cold', and 'hot'; NULL for new scale)

bias
  • ??

space
  • colorspace ('rgb' or 'Lab')

interpolate
  • interpolation scheme ('linear' or 'spline')

showAsWheel
  • flag (T/F) to show the final palette as a colorwheel

showAsBar
  • flag (T/F) to show final palette as a colorbar

Details

New color scales can be created based on pre-defined color vectors using the following names:
'jet', 'coldhot', 'cold', and 'hot'
Specifying a pre-defined name eliminates the need to specify the 'clrs' color vector.
Arbitrary scales can created by specifying NULL for 'name' (the default) and providing a vector of colors to use to define the scale function. This uses the grDevices package function "colorRamp" to define the underlying color ramp used for the scale. Uses packages graphics and grDevices].

Value

a function reflecting a color scale.


wStockhausen/wtsUtilities documentation built on Aug. 18, 2024, 11:48 p.m.