Function to define a colormap

Description

visColormap is supposed to define a colormap. It returns a function, which will take an integer argument specifying how many colors interpolate the given colormap.

Usage

visColormap(colormap = c("bwr", "jet", "gbr", "wyr", "br", "yr", "rainbow", "wb", 
  "heat", "terrain", "topo", "cm"))

Arguments

colormap
short name for the colormap. It can also be a function of 'colorRampPalette'

Value

  • palette.name: a function that takes an integer argument for generating that number of colors interpolating the given sequence

Note

The input colormap includes:

  • "jet": jet colormap
  • "bwr": blue-white-red
  • "gbr": green-black-red
  • "wyr": white-yellow-red
  • "br": black-red
  • "yr": yellow-red
  • "wb": white-black
  • "rainbow": rainbow colormap, that is, red-yellow-green-cyan-blue-magenta
  • Alternatively, any hyphen-separated HTML color names, e.g. "blue-black-yellow", "royalblue-white-sandybrown", "darkblue-lightblue-lightyellow-darkorange", "darkgreen-white-darkviolet", "darkgreen-lightgreen-lightpink-darkred". A list of standard color names can be found in http://html-color-codes.info/color-names

Examples

# 1) define "blue-white-red" colormap palette.name <- visColormap(colormap="bwr") # 2) use the return function "palette.name" to generate 10 colors spanning "bwr" palette.name(10)
[1] "#0000FF" "#3838FF" "#7171FF" "#AAAAFF" "#E2E2FF" "#FFE2E2" "#FFAAAA" [8] "#FF7171" "#FF3838" "#FF0000"

Source code

visColormap.r

Source man

visColormap.Rd visColormap.pdf

See also

visColoralpha