getDiscreteColors {easy.utils}R Documentation

Generate palettes of distinct colors

Description

Generate palettes of distinct colors

Usage

getDiscreteColors(
  n,
  pal = NULL,
  is.extend = TRUE,
  random = c("no", "randomColor", "distinctColorPalette", "Polychrome"),
  seed = 1234,
  verbose = FALSE,
  ...
)

setColor(x, pal = NULL, ...)

Arguments

n

How many colors do we need?

pal

Name of the palette to use. Use names(pal_discrete) to get all palette names

is.extend

When n > length(pal_discrete[[pal]]), whether or not to extend the colors with colorRampPalette.

random

Choose a method to generate random colors. Default is "no".

seed

Seed for random colors.

verbose

Show progress messages.

...

Extra parameters passed to other functions depending on random:

  • randomColor() or distinctColorPalette(). This requires manual installation of randomcoloR

  • createPalette from Polychrome

x

A factor to use colors.

Value

A vector with n colors. For setColor, also set names as factor levels.

Examples

getDiscreteColors(10)
getDiscreteColors(
  10, 
  random = "Polychrome", 
  seedcolors = scales::hue_pal()(4)
)

## Assign colors for a character or factor vector.
xx <- sample(LETTERS, 10)
cols <- setColor(xx)


[Package easy.utils version 0.0.4 Index]