MyNixOS website logo
Description

Methods for Colour Vectors and Colour Palettes.

Provides a comprehensive library for colour vectors and colour palettes using a new family of colour classes (palettes_colour and palettes_palette) that always print as hex codes with colour previews. Capabilities include: formatting, casting and coercion, extraction and updating of components, plotting, colour mixing arithmetic, and colour interpolation.

palettes

R-CMD-check Codecov testcoverage CRANstatus CRANdownloads

palettes is an R package for working with colour vectors and colour palettes. There are three main goals to the palettes package, each described in a vignette:

  • To provide a new family of colour classes (palettes_colour and palettes_palette) that always print as hex codes with colour previews; vignette("palettes").

  • To provide a comprehensive library of methods for working with colour vectors and colour palettes, including methods for ggplot2, vignette("ggplot2"); gt, vignette("gt"); biscale, vignette("biscale"); and other colour packages, vignette("compatibility").

  • To make it easy for anyone to make their own colour palette package; vignette("creating-packages"). Colour palette packages made with palettes exist solely for the purpose of distributing colour palettes and get access to all the features of palettes for free.

Installation

Install palettes from CRAN with:

install.packages("palettes")

Install the development version from GitHub or R-universe with:

# Install from GitHub
# install.packages("remotes")
remotes::install_github("mccarthy-m-g/palettes")

# Install from R-universe
install.packages("palettes", repos = "https://mccarthy-m-g.r-universe.dev")

Install the WebAssembly version for use in WebR applications with:

# Install CRAN version from r-wasm
install.packages("palettes", repos = "https://repo.r-wasm.org")

# Install development version from R-universe
install.packages(
  "palettes",
  repos = c("https://mccarthy-m-g.r-universe.dev", "https://repo.r-wasm.org")
)

Usage

library(palettes)

Colours can be specified by name (as listed by grDevices::colours()):

pal_colour("red")

Or by hex code:

pal_colour("#FF0000")

Multiple colours can be specified at once as a character vector:

pal_colour(c("#a00e00", "#d04e00", "#f6c200", "#0086a8", "#132b69"))

Named colour palettes can be specified in the same way:

pal_palette(
  egypt = c("#dd5129", "#0f7ba2", "#43b284", "#fab255"),
  java  = c("#663171", "#cf3a36", "#ea7428", "#e2998a", "#0c7156")
)

Colours also print nicely in tibbles:

as_tibble(pal_colour(c("#dd5129", "#0f7ba2", "#43b284", "#fab255")))

Documentation

See at https://mccarthy-m-g.github.io/palettes/ and also in the installed package: help(package = "palettes").

License

MIT © Michael McCarthy.

Metadata

Version

0.2.1

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