Returns colors for data visualization and EKIO identity work. Includes EKIO
brand scales, accent and categorical palettes, the ekio_brand identity
palette, the EKIO Academy palettes, and standard scientific palettes.
When printed interactively, displays the palette as a colored swatch with
hex labels.
Source
The brand scales are generated from one OKLCH specification in
data-raw/build-ramps.R: a shared lightness spine anchored on the brand
navy, a shared chroma arc, and a hue path per family. The scientific
palettes come from matplotlib ("viridis", "inferno", "plasma") and
from Okabe & Ito ("okabe_ito"). Notices are in inst/COPYRIGHTS.
Arguments
- palette
Character. Name of the palette. See
list_ekio_palettes()for all available options.- n
Integer or NULL. Number of colors to return. If NULL, returns all, except
"accent_blue"and"accent_orange", which return four by default. For sequential, diverging and academy palettes,ncolors are interpolated across the full range. For the two variable-size accent palettes,ncan be between 2 and 6. For"gold", other categorical palettes, and scientific palettes, the firstncolors are taken, interpolating only ifnexceeds the palette length.- reverse
Logical. If TRUE, reverses the palette order.
Value
Object of class ekio_palette (a character vector of hex
codes). Printing displays a visual swatch. Use as.character() to
strip the class.
Details
Brand scales ("blue", "gray", "stone", "teal", "green",
"orange", "red", "purple") are nine-step ramps running light to dark,
named by shade. Position and shade are aligned by construction, so
ekio_pal("blue")[7] and ekio_pal("blue")["700"] are the same color.
Subsetting drops the names. A color picked out of a scale goes straight
into ggplot2::scale_color_manual(), which reads names as data levels.
The whole palette keeps its names for ekio_text_on() and for lookup.
The named "ekio_brand" palette contains colors for EKIO identity assets.
It is not intended as a general-purpose data visualization palette.
The "academy" palettes, "yoro_blue" and "yoro_green", are for EKIO
Academy tutorials and books. They come from Hokusai's Yoro Waterfall in
Mino Province and are tuned for theme_ekio(background = "cold"). Each is
a five-step ramp, light to dark, and the two share one lightness per step.
Steps 4 and 5 are dark enough for text on the cold surface.
"full_light" and "spectrum_light" are lighter categorical palettes for
filled marks such as bars, boxplots, and areas. "full_light" keeps the
order of "full", so neighboring colors differ in hue. "spectrum_light"
follows the color wheel from blue to purple, which suits ordered
categories.
"gold" is an accent rather than a scale: three colors named "light",
"mid" and "deep", because a nine-step gold ramp turns brown at the
dark end. They sit on the same lightness rungs as scale shades 300, 400
and 500.
"accent_blue" and "accent_orange" put one main color before a sequence
of receding grays. They return four colors by default; n can be set from
2 to 6 to match the number of series while keeping the main color first.
Examples
ekio_pal("full")
ekio_pal("full", n = 4)
ekio_pal("full", reverse = TRUE)
ekio_pal("full_light")
ekio_pal("spectrum_light")
ekio_pal("accent_blue", n = 5)
ekio_pal("okabe_ito")
ekio_pal("ekio_brand")
ekio_pal("yoro_blue")
# Brand scales are named by shade; position i is shade i * 100
ekio_pal("blue")["700"]
#> [1] "#1E3A5F"
ekio_pal("blue")[7]
#> [1] "#1E3A5F"
# gold is an accent, named rather than numbered
ekio_pal("gold")["mid"]
#> [1] "#B4840C"
# Subsets are unnamed, so a hand-built palette needs no unname()
c(ekio_pal("blue")["700"], ekio_pal("orange")["500"])
#> [1] "#1E3A5F" "#AB5000"
