Package 'ggokabeito'

Title: 'Okabe-Ito' Scales for 'ggplot2' and 'ggraph'
Description: Discrete scales for the colorblind-friendly 'Okabe-Ito' palette, including 'color', 'fill', and 'edge_colour'. 'ggokabeito' provides 'ggplot2' and 'ggraph' scales to easily use the 'Okabe-Ito' palette in your data visualizations.
Authors: Malcolm Barrett [aut, cre]
Maintainer: Malcolm Barrett <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0.9000
Built: 2024-11-10 03:45:00 UTC
Source: https://github.com/malcolmbarrett/ggokabeito

Help Index


Okabe-Ito Palette

Description

palette_okabe_ito() is a wrapper around palette.colors() that returns the Okabe-Ito palette in R 4.0.0 or greater. palette_okabe_ito() returns an unnamed vector of colors for better use with ggplot2. Additionally, black is the last color returned by palette_okabe_ito() when 9 colors are needed instead of the first, as in palette.colors().

Usage

palette_okabe_ito(order = 1:9, alpha = NULL, recycle = FALSE)

Arguments

order

A numeric vector, the order of the colors, or a character vector of color names, of: "black", "orange", "skyblue", "bluishgreen", "yellow", "blue", "vermillion", "reddishpurple", "gray". If alpha is not NULL, you must use an integer vector since the colors are not returned with names.

alpha

an alpha-transparency level in the range [0,1] (0 means transparent and 1 means opaque).

recycle

logical indicating what happens in case n > length(palette(.)). By default (recycle = FALSE), the result is as for n = NULL, but with a warning.

Value

A character vector of hex codes

Examples

palette_okabe_ito()

palette_okabe_ito(order = c(2, 3, 5), alpha = 0.9)

palette_okabe_ito(order = c("bluishgreen", "yellow", "blue"))

Okabe-Ito Scales for ggplot2 and ggraph

Description

Discrete scales for the colorblind-friendly Okabe-Ito palette, including color, fill, and edge_colour. See palette_okabe_ito for details.

Usage

scale_okabe_ito(aesthetics, order = 1:9, alpha = 1, ...)

scale_colour_okabe_ito(aesthetics = "colour", order = 1:9, alpha = NULL, ...)

scale_color_okabe_ito(aesthetics = "colour", order = 1:9, alpha = NULL, ...)

scale_fill_okabe_ito(aesthetics = "fill", order = 1:9, alpha = NULL, ...)

scale_edge_colour_okabe_ito(
  aesthetics = "edge_colour",
  order = 1:9,
  alpha = NULL,
  ...
)

scale_edge_color_okabe_ito(
  aesthetics = "edge_colour",
  order = 1:9,
  alpha = NULL,
  ...
)

Arguments

aesthetics

The names of the aesthetics that this scale works with.

order

A numeric vector, the order of the colors, or a character vector of color names, of: "black", "orange", "skyblue", "bluishgreen", "yellow", "blue", "vermillion", "reddishpurple", "gray". If alpha is not NULL, you must use an integer vector since the colors are not returned with names.

alpha

an alpha-transparency level in the range [0,1] (0 means transparent and 1 means opaque).

...

Additonal arguments passed to ggplot2::discrete_scale()

Value

A ggplot or ggraph scale

Examples

library(ggplot2)

ggplot(mpg, aes(cty, hwy, color = class)) +
  geom_point() +
  scale_color_okabe_ito()

ggplot(mpg, aes(cty, hwy, color = factor(cyl))) +
  geom_point(alpha = 0.7) +
  scale_color_okabe_ito(name = "Cylinders", alpha = .9)

ggplot(mpg, aes(hwy, color = class, fill = class)) +
  geom_density() +
  scale_fill_okabe_ito(name = "Class", alpha = .9) +
  scale_color_okabe_ito(name = "Class")