MyNixOS website logo
Description

Automatic Generation of Qualitative Color Palettes.

Automatic generation of maximally distinct qualitative color palettes, optionally tailored to color deficiency. A list of colors or a subspace of a color space is used as input and then projected to the DIN99d color space, where colors that are maximally distinct are chosen algorithmically.

qualpalr

R-CMD-check Codecov testcoverage CRAN_Status_Badge

qualpalr generates distinct qualitative color palettes, primarily for use in R graphics. Given n (the number of colors to generate), along with a subset in the hsl color space (a cylindrical representation of the RGB color space) qualpalr attempts to find the n colors in the provided color subspace that maximize the smallest pairwise color difference. This is done by projecting the color subset from the HSL color space to the DIN99d space. DIN99d is (approximately) perceptually uniform, that is, the euclidean distance between two colors in the space is proportional to their perceived difference.

qualpalr was inspired by i want hue.

Usage

Let’s create a palette of 4 colors of hues from 0 to 360, saturation between 0.1 and 0.5, and lightness from 0.6 to 0.85.

library(qualpalr)

pal <- qualpal(n = 4, list(h = c(0, 360), s = c(0.1, 0.5), l = c(0.6, 0.85)))

We can retrieve the generated colors in hex format

pal$hex
#> [1] "#74C970" "#766AC9" "#C86D6A" "#DCCFE0"

Alternatively, we can create a palette using one of the predefined color subspaces and, optionally, adapt it to color deficiency (here deuteranomaly).

pal2 <- qualpal(
  n = 4,
  colorspace = "pretty",
  cvd = "deutan",
  cvd_severity = 0.5
)

We can look at a distance matrix of the pairwise color differences from the palette we have generated.

pal2$de_DIN99d
#>          #D4C76F  #616FC8  #D0E0E8
#> #616FC8 29.14409                  
#> #D0E0E8 18.78602 21.76547         
#> #A08587 18.59491 18.38472 18.34490

The palette may also be plotted with in a multidimensional scaling plot generated from the distance matrix of the colors in the palette.

plot(pal2)

Or it might be plotted in one of the provided color spaces as a scatterplot matrix.

pairs(pal2, colorspace = "HSL")

Installation

The current CRAN release can be installed by running

install.packages("qualpalr")

The development version can be installed by running

devtools::install_github("jolars/qualpalr")

Versioning

Versioning is based on semantic versioning.

Code of conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

qualpalr is open source software, licensed under GPL-3.

Metadata

Version

0.4.4

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows