xColormap: Function to define a colormap

View source: R/xColormap.r

xColormapR Documentation

Function to define a colormap

Description

xColormap 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

xColormap(
colormap = c("bwr", "jet", "gbr", "wyr", "br", "yr", "rainbow", "wb",
"heat",
"terrain", "topo", "cm", "ggplot2", "jet.top", "jet.bottom",
"jet.both", "spectral",
"ggplot2.top", "ggplot2.bottom", "ggplot2.both", "RdYlBu",
"brewer.BrBG",
"brewer.PiYG", "brewer.PRGn", "brewer.PuOr", "brewer.RdBu",
"brewer.RdGy",
"brewer.RdYlBu", "brewer.RdYlGn", "brewer.Spectral", "brewer.Blues",
"brewer.BuGn",
"brewer.BuPu", "brewer.GnBu", "brewer.Greens", "brewer.Greys",
"brewer.Oranges",
"brewer.OrRd", "brewer.PuBu", "brewer.PuBuGn",
"brewer.PuRd", "brewer.Purples",
"brewer.RdPu", "brewer.Reds", "brewer.YlGn", "brewer.YlGnBu",
"brewer.YlOrBr",
"brewer.YlOrRd", "rainbow_hcl", "heat_hcl", "terrain_hcl",
"diverge_hcl", "hcl_br",
"hcl_bp", "hcl_bb", "hcl_gp", "hcl_go", "hcl_cp", "hcl_cy", "hcl_co",
"sci_jco",
"sci_lancet", "sci_nejm", "sci_locuszoom"),
interpolate = c("spline", "linear"),
data = NULL,
zlim = NULL
)

Arguments

colormap

short name for the colormap. It can be one of "jet" (jet colormap), "bwr" (blue-white-red colormap), "gbr" (green-black-red colormap), "wyr" (white-yellow-red colormap), "br" (black-red colormap), "yr" (yellow-red colormap), "wb" (white-black colormap), "rainbow" (rainbow colormap, that is, red-yellow-green-cyan-blue-magenta), and "ggplot2" (emulating ggplot2 default color palette). Alternatively, any hyphen-separated HTML color names, e.g. "lightyellow-orange" (by default), "blue-black-yellow", "royalblue-white-sandybrown", "darkgreen-white-darkviolet". A list of standard color names can be found in http://html-color-codes.info/color-names. It can also be a function of 'colorRampPalette'. It can also be "brewer.*" (RColorBrewer palette; see RColorBrewer::display.brewer.all()). It can be colorspace defaults ("rainbow_hcl","heat_hcl","terrain_hcl","diverge_hcl") or other useful ones ("hcl_br","hcl_bp","hcl_bb","hcl_gp","hcl_go","hcl_cp","hcl_cy","hcl_co")

interpolate

use spline or linear interpolation

data

NULL or a numeric vector

zlim

the minimum and maximum z/patttern values for which colors should be plotted, defaulting to the range of the finite values of z. Each of the given colors will be used to color an equispaced interval of this range. The midpoints of the intervals cover the range, so that values just outside the range will be plotted

Value

palette.name (a function that takes an integer argument for generating that number of colors interpolating the given sequence) or mapped colors if data is provided.

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

  • "ggplot2": emulating ggplot2 default color palette

  • "spectral": emulating RColorBrewer spectral color palette

  • 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

See Also

xColormap

Examples

# 1) define "blue-white-red" colormap
palette.name <- xColormap(colormap="bwr")
# use the return function "palette.name" to generate 10 colors spanning "bwr"
palette.name(10)

# 2) define default colormap from ggplot2
palette.name <- xColormap(colormap="ggplot2")
# use the return function "palette.name" to generate 3 default colors used by ggplot2
palette.name(3)

# 3) define brewer colormap called "RdYlBu"
palette.name <- xColormap(colormap="RdYlBu")
# use the return function "palette.name" to generate 3 default colors used by ggplot2
palette.name(3)

# 4) return mapped colors
xColormap(colormap="RdYlBu", data=runif(5))

hfang-bristol/XGR documentation built on Feb. 4, 2023, 7:05 a.m.