Colour palettes inspired by sunsets in the Canadian Prairies.
The main purpose of sunsets is to serve as an example showing how to create a colour palette package with the palettes package. See the accompanying Creating a colour palette package vignette for a step-by-step guide.
The palettes package 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. Colour palette packages created with
palettes have access to the following capabilities, all without
requiring you to write any code: formatting, casting and coercion,
extraction and updating of components, plotting, colour mixing
arithmetic, and colour interpolation.
See the following vignettes to learn how to use sunsets’ palettes with other packages:
- Using palettes with ggplot2
- Using palettes with gt
- Using palettes with biscale
- Compatibility with other colour packages
You can install the development version of sunsets from GitHub with:
# install.packages("devtools")
devtools::install_github("mccarthy-m-g/sunsets")library(sunsets)
#> Loading required package: palettessunsets comes with a set of 2 discrete colour palettes, and 5 sequential colour palettes, which can be accessed from the following R objects:
sunset_palettes_discretefor discrete palettessunset_palettes_sequentialfor sequential palettessunset_palettesfor all palettes
To preview the palettes in the console simply print them:
sunset_palettes_discreteTo preview the palettes in the Plots pane use plot():
plot(sunset_palettes_sequential)To cast palettes to a tibble use as_tibble():
as_tibble(sunset_palettes)Palettes can be subset using [, [[, and $.
-
To extract one or more palettes use
[:sunset_palettes_sequential[c("blue", "green")]
-
To extract a single palette as a colour vector use
[[or$:sunset_palettes_sequential[["purple"]]
sunset_palettes_sequential$purple
-
To get names of palettes use
names():names(sunset_palettes_sequential) #> [1] "orange" "blue" "yellow" "green" "purple"
See also documentation for the palettes package at
https://mccarthy-m-g.github.io/palettes/
or in the installed package: help(package = "palettes").
CC0

