DefineColorMap: Definition of ColorParameters

View source: R/DefineColorMap.R

DefineColorMapR Documentation

Definition of ColorParameters

Description

DefineColorMap provides a general method to define piecewise translations of numeric values into colors. It can be used in combination with MakeColors and ColorLegend to produce plots with precise and easy to interpret color informations.

Usage

DefineColorMap(
  thresholds = NULL,
  colors = NULL,
  range = NULL,
  number = NULL,
  below = NA,
  above = NA,
  na = NA,
  levels = 256,
  centered = FALSE,
  extra = NULL,
  name = ""
)

Arguments

thresholds

numeric vector defining the boundaries for each range of values to be mapped into a specific color interval. When unspecified, thresholds are automatically set according to the range and the colors or number parameters.

colors

color vector providing the colors representing each threshold value (default = rainbow).

range

range of the numeric values to be represented (default = range(thresholds)).

number

the number of color intervals, used only if thresholds and colors are unspecified (default = 2 in that case).

below

color used for all values below the minimum threshold (defaut = NA, not visible).

above

color used for all values above the maximum threshold (defaut = NA, not visible).

na

color used for missing (NA) values (defaut = NA, not visible).

levels

integer vector controlling the number of color levels generated in each color interval (default = 256, minimum = 2).

centered

logical value.

extra

numeric value between 1.0 and above, defining the fraction of the colorscale used to represent below and above colors with ColorLegend. The default values are either 1.0, 1.15 or 1.2, depending how below and above colors are specified.

name

recall a predefined set of color mapping parameters.

Value

DefineColorMap returns a ColorParameters object which consists in a list containing the following elements: thresholds, colors, range, number, below, above, na, levels, centered, extra, name.

See Also

UpdateDefinition, MakeColors, ColorLegend, DefineGroupStyles

Examples


# Radial color gradient with two normally distributed random variables
x <- rnorm(2000)
y <- rnorm(2000)
z <- 2 * sqrt(x^2 + y^2)

col.par <- DefineColorMap(seq(0, 5, 1))
clrs    <- MakeColors(z, parameters = col.par)

plot(x, y, xlim = c(-3, 3), ylim = c(-3, 3), pch = 20, col = clrs)
ColorLegend("topright", parameters = col.par)

benja0x40/Barbouille documentation built on March 26, 2023, 11:38 p.m.