factor2color

0th

Percentile

Assign colours to factor vector

This function takes a factor vector and returns suitable colours representing the factor levels. Default is to try to use RColorBrewer for colours, and rainbow otherwise. Can provide custom colours.

Usage
factor2color(x, colors = NULL)
Arguments
x

A factor vector.

colors

The colours to use. Defaults to a qualitative colour scheme; either "Set3" from RColorBrewer if available, or rainbow otherwise.

Details

Uses the RColorBrewer package if installed. Coerces x to factor with a warning.

Value

A character vector of colours.

See Also

cont2color

Aliases
  • factor2color
Examples
# NOT RUN {
plot(iris[, c("Petal.Length", "Petal.Width")], pch = 21,
  bg = factor2color(iris$Species))
legend("topleft", legend = levels(iris$Species),
  fill = factor2color(as.factor(levels(iris$Species))))

# }
Documentation reproduced from package condvis, version 0.5-1, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.