Skip to contents

n distinct colors, never recycled. The first 18 are dagviz.style.colors.palette()'s colors (6 hues at 3 lightness levels, in dagviz's order, minus the 3 duplicates that its 7th hue step produces by wrapping around to the 1st). Further colors are generated deterministically in HCL space, each kept only if it is perceptibly different from all earlier ones. metro_palette(k) is always the first k colors of metro_palette(n) for k <= n. Colors get harder to tell apart as n grows large (beyond roughly 100).

Usage

metro_palette(n)

Arguments

n

Number of colors to generate.

Value

A character vector of n distinct hex colors.

Examples

metro_palette(5)
#> [1] "#c65353" "#c6c653" "#53c653" "#53c6c6" "#5353c6"

# as a row of color swatches
swatches <- data.frame(x = 1:24, color = metro_palette(24))
ggplot2::ggplot(swatches, ggplot2::aes(x, 1, fill = I(color))) +
  ggplot2::geom_tile() +
  ggplot2::theme_void()