ChartColors: Generates a vector of colors

View source: R/chartcolors.R

ChartColorsR Documentation

Generates a vector of colors

Description

Generates a vector of colors from a palette or vector of colors. Alpha channels are ignored and set to 255/FF.

Usage

ChartColors(
  number.colors.needed,
  given.colors,
  reverse = FALSE,
  palette.start = 0,
  palette.end = 1,
  trim.light.colors = TRUE,
  custom.color = NA,
  custom.gradient.start = NA,
  custom.gradient.end = NA,
  custom.palette = NA,
  silent = FALSE,
  silent.single.color = silent
)

Arguments

number.colors.needed

The number of colors to generate.

given.colors

Specifies the color vector to output. It can be; (1) A named palette from grDevices, RColorBrewer colorspace, or colorRamps; (2) A vector of colors which will be recycled to length number.colors.needed; or (3) one of "Custom color", "Custom gradient" or "Custom palette". The last option gives the user greater control via additional parameters (see below). If not specified, the colors used are c("#5C9AD3", "#ED7D31", "#A5A5A5", "#FFC000", "#4473C5", "#70AD46", "#255F91", "#9E480D", "#636365", "#987300", "#26408B", "#42682B")

reverse

Whether the output color vector should be reversed. Ignored when given.colors is any of "Custom color", "Custom gradient" or "Custom palette".

palette.start

A numeric in [0,1] specifying the start of the palette relative to the full spectrum of given.colors. The default is 0, which means the palette starts with the first color of given.colors.

palette.end

A numeric in [0,1] specifying the end of the palette relative to the full spectrum of given.colors. The default is 1, which means the palette starts with the last color of given.colors.

trim.light.colors

When selected, palette.start and palette.end will be set to remove light colors in the monochrome palettes ("Blues","Greens","Greys","Oranges","Purples","Reds"), if this is not already achieved by palette.start and palette.end.

custom.color

A single color provided as a hex or character string. Only used if given.colors is "Custom color". The output vector will consist of custom.color repeated number.colors.needed (no interpolation).

custom.gradient.start

A color specifying the start of the gradient when given.colors is set to "Custom gradient".

custom.gradient.end

A color specifying the end of the gradient when given.colors is set to "Custom gradient".

custom.palette

A vector or comma separated list of colors which will be recycled to the desired length. Only used if given.colors is "Custom palette".

silent

Option to hide warnings about the number of colors.

silent.single.color

Option to hide warnings if only a single color is provided when number.colors.needed > 1. This type of warning is controlled separately from the silent because there are some chart types for which a single color or a palette can be appropriately specified. In contrast the times when colors need to recycled for fill the palette, or the a palette is used for a single color usually indicates the user has specified some inappropriate options.

Examples

ChartColors(5, given.colors = c("blue", "orange", "green"))
ChartColors(5, given.colors = "blue")
ChartColors(5, given.colors = "#9CFF73")
ChartColors(5, given.colors = "Set3", reverse = TRUE)
plot(1:10,1:10,pch=19, col=ChartColors(10,"Reds",trim.light.colors=TRUE, reverse=TRUE))
plot(1:12, 1:12, pch=19, col=ChartColors(12))

NumbersInternational/flipChartBasics documentation built on Feb. 26, 2024, 5:34 a.m.