gl.colors: Returns a list of colors for use in plots

View source: R/gl.colors.r

gl.colorsR Documentation

Returns a list of colors for use in plots

Description

Creates a vector of colors in hex (e.g. "#3B9AB2" "#78B7C5") based on user selected category (parameter type).

  • "2" [two colors]

  • "2c" [two colors contrast]

  • "3" [three colors]

  • "4" [four colors]

  • "structure" [35 discrete colors, suitable for structure-style plots]

  • "div", "dis", "con", "vir" [color palettes, see details]

Usage

gl.colors(type = 2, verbose = NULL)

Arguments

type

Type of color (2, 3 or 4 colors, "structure", or a palette type, see description) [default 2].

verbose

Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log; 3, progress and results summary; 5, full report [default 2 or as specified using gl.set.verbosity].

Details

A palette of colors can be specified via "div" [divergent], "dis" [discrete], "con" [convergent], "vir" [viridis]. Be aware a palette needs the number of colors specified as well. It returns a function and therefore the number of colors needs to be a part of the function call. Check the examples to see how this works.

Value

A vector of colors in hex format, or, for the palette types ("div", "dis", "con", "vir"), a function taking the number of colors as its argument.

Author(s)

Author(s): Bernd Gruber. Custodian: Bernd Gruber – Post to https://groups.google.com/d/forum/dartr

See Also

Other graphics: gl.map.interactive(), gl.plot.heatmap(), gl.plot.snp.density(), gl.select.colors(), gl.select.shapes(), gl.smearplot(), gl.tree.nj()

Examples

gl.colors(2)
gl.colors("2")
gl.colors("2c")
#five discrete colors
gl.colors(type="dis")(5)
#seven divergent colors
gl.colors("div")(7)


dartR.base documentation built on Nov. 18, 2026, 9:06 a.m.