Package 'wacolors'

Title: Colorblind-Friendly Palettes from Washington State
Description: Color palettes taken from the landscapes and cities of Washington state. Colors were extracted from a set of photographs, and then combined to form a set of continuous and discrete palettes. Continuous palettes were designed to be perceptually uniform, while discrete palettes were chosen to maximize contrast at several different levels of overall brightness and saturation. Each palette has been evaluated to ensure colors are distinguishable by colorblind people.
Authors: Cory McCartan [aut, cre]
Maintainer: Cory McCartan <[email protected]>
License: MIT + file LICENSE
Version: 0.3.1
Built: 2024-11-24 02:53:38 UTC
Source: https://github.com/CoryMcCartan/wacolors

Help Index


Output a character vector containing code for a ggplot2 scale

Description

Call this function to get the code for the ⁠scale_*⁠ functions for a palette. If using RStudio, the code will be loaded at the console prompt; otherwise, it will be printed at the terminal. Assumes that ggplot2 has been loaded into the namespace, or will be by the time the scales are used.

Usage

pal_functions(
  palette,
  which = NULL,
  type = c("discrete", "continuous"),
  reverse = FALSE
)

Arguments

palette

a ⁠[wacolors]⁠ palette or palette name.

which

if not NULL, the indices or names of a subset of colors to use.

type

Either continuous, discrete, or binned. Use continuous if you want to automatically interpolate between colors. Custom scale midpoints are not supported (see scale_fill_wa_c()).

reverse

TRUE if the colors should be reversed.

Value

The generated code, invisibly, as a character vector.

Examples

pal_functions("rainier")

Output a character vector containing code for a palette

Description

Call this function to get the code for a character vector containing a palette. If using RStudio, the code will be loaded at the console prompt; otherwise, it will be printed at the terminal.

Usage

pal_vector(
  palette,
  n,
  which = NULL,
  type = c("discrete", "continuous"),
  reverse = FALSE
)

Arguments

palette

The name of the palette (partial matching supported), or an actual palette from ⁠[wacolors]⁠.

n

The number of colors in the palette. If this exceeds the actual number and type is not provided, it will be set to continuous.

which

if not NULL, the indices or names of a subset of colors to use.

type

Either continuous or discrete. Use continuous if you want to automatically interpolate between colors.

reverse

TRUE if palette should be reversed.

Value

The generated code, invisibly, as a character vector.

Examples

pal_vector("rainier", 4)

Color palettes for ggplot2

Description

Color palettes for ggplot2

Usage

scale_color_wa_d(palette = "rainier", which = NULL, ..., reverse = FALSE)

scale_fill_wa_d(palette = "rainier", which = NULL, ..., reverse = FALSE)

scale_color_wa_c(
  palette = "sound_sunset",
  which = NULL,
  midpoint = NULL,
  ...,
  reverse = FALSE
)

scale_fill_wa_c(
  palette = "sound_sunset",
  which = NULL,
  midpoint = NULL,
  ...,
  reverse = FALSE
)

scale_color_wa_b(palette = "sound_sunset", which = NULL, ..., reverse = FALSE)

scale_fill_wa_b(palette = "sound_sunset", which = NULL, ..., reverse = FALSE)

scale_colour_wa_d(palette = "rainier", which = NULL, ..., reverse = FALSE)

scale_colour_wa_c(
  palette = "sound_sunset",
  which = NULL,
  midpoint = NULL,
  ...,
  reverse = FALSE
)

scale_colour_wa_b(palette = "sound_sunset", which = NULL, ..., reverse = FALSE)

Arguments

palette

a wacolors palette or palette name.

which

if not NULL, the indices or names of a subset of colors to use.

...

Other arguments passed on to ggplot2::discrete_scale(), ggplot2::continuous_scale(), or ggplot2::binned_scale() to control name, limits, breaks, labels and so forth.

reverse

TRUE if the colors should be reversed.

midpoint

if not NULL and at least one limit is not provided, the value to center the scale at. Useful for diverging scales.

Value

A ggplot2::Scale object.

Examples

library(ggplot2)

ggplot(mtcars, aes(mpg, wt)) +
    geom_point(aes(color = factor(cyl), size=hp)) +
    scale_color_wa_d()

ggplot(mtcars, aes(mpg, wt)) +
    geom_point(aes(color = hp)) +
    scale_color_wa_c("palouse",  which=c("snake", "wheat"))

ggplot(diamonds) +
    geom_bar(aes(x = cut, fill = clarity)) +
    scale_fill_wa_d(wacolors$sound_sunset, reverse=TRUE)

Washington State Color Palette Generator

Description

Generate palette objects from the wacolors list

Usage

wa_pal(
  palette,
  n,
  which = NULL,
  type = c("discrete", "continuous"),
  reverse = FALSE
)

Arguments

palette

The name of the palette (partial matching supported), or an actual palette from ⁠[wacolors]⁠.

n

The number of colors in the palette. If this exceeds the actual number and type is not provided, it will be set to continuous.

which

if not NULL, the indices or names of a subset of colors to use.

type

Either continuous or discrete. Use continuous if you want to automatically interpolate between colors.

reverse

TRUE if palette should be reversed.

Value

A vector of colors of type palette. Use the plot() function to plot the palette. If the cli package is installed, printing the palette to the console will also show its colors.

Examples

wa_pal("rainier")
wa_pal(wacolors$rainier)
wa_pal("sound_sunset", 20, "continuous")
wa_pal("washington_pass", reverse=TRUE)

Washington State Color Palettes

Description

A collection of colorblind-friendly color palettes for various settings in the state of Washington. Colors were extracted from a set of photographs, and then combined to form a set of continuous and discrete palettes. Continuous palettes were designed to be perceptually uniform, while discrete palettes were chosen to maximize contrast at several different levels of overall brightness and saturation. Each palette has been evaluated to ensure colors are distinguishable by colorblind people.

Usage

wacolors

Format

A list of character vectors containing the color palettes. Discrete palette vectors contain names for each color.

Details

Discrete palettes contain at most seven colors. Don't create graphics that use more than seven discrete colors. You can color a map with four. Anything more risks confusion. Consider differentiating through faceting or labels, instead.

Available continuous palettes:

README-cont-palettes-1.png

README-cont-palettes-2.png

README-cont-palettes-3.png

README-cont-palettes-4.png

README-cont-palettes-5.png

README-cont-palettes-6.png

README-cont-palettes-7.png

README-cont-palettes-8.png

README-cont-palettes-9.png

README-cont-palettes-10.png

README-cont-palettes-11.png

README-cont-palettes-12.png

README-cont-palettes-13.png

README-cont-palettes-14.png

README-cont-palettes-15.png

README-cont-palettes-16.png

README-cont-palettes-17.png

Available discrete palettes:

README-disc-palettes-1.png

README-disc-palettes-2.png

README-disc-palettes-3.png

README-disc-palettes-4.png

README-disc-palettes-5.png

README-disc-palettes-6.png

README-disc-palettes-7.png

README-disc-palettes-8.png

README-disc-palettes-9.png

README-disc-palettes-10.png

README-disc-palettes-11.png

Examples

wacolors$rainier
wacolors$palouse[1:4]