MyNixOS website logo
Description

'Okabe-Ito' Scales for 'ggplot2' and 'ggraph'.

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.

ggokabeito

R-CMD-check Codecov testcoverage CRANstatus Lifecycle:experimental

ggokabeito provides ggplot2 and ggraph scales to easily use the discrete, colorblind-friendly ‘Okabe-Ito’ palette in your data visualizations. Currently, ggokabeito provides the following scales:

  • scale_color_okabe_ito()/scale_colour_okabe_ito()
  • scale_fill_okabe_ito()
  • scale_edge_color_okabe_ito()/scale_edge_colour_okabe_ito()

Installation

You can install ggokabeito from CRAN with:

install.packages("ggokabeito")

You can alternatively install the development version of ggokabeito from GitHub with:

# install.packages("devtools")
devtools::install_github("malcolmbarrett/ggokabeito")

Examples

library(ggokabeito)
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")

ggokabeito also works with ggraph

# example from https://www.data-imaginist.com/2017/ggraph-introduction-edges/
library(ggraph, warn.conflicts = FALSE)
library(igraph, warn.conflicts = FALSE)

graph <- graph_from_data_frame(highschool)
pop1957 <- degree(
  delete_edges(graph, which(E(graph)$year == 1957)),
  mode = "in"
)
pop1958 <- degree(
  delete_edges(graph, which(E(graph)$year == 1958)),
  mode = "in"
)
V(graph)$pop_devel <- ifelse(
  pop1957 < pop1958,
  "increased",
  ifelse(pop1957 > pop1958, "decreased",
         "unchanged"
  )
)

V(graph)$popularity <- pmax(pop1957, pop1958)
E(graph)$year <- as.character(E(graph)$year)

ggraph(graph, layout = "kk") +
  geom_edge_link(aes(colour = as.character(year))) +
  scale_edge_color_okabe_ito()

Similar work

ggokabeito is heavily inspired by the excellent colorblindr package. However, colorblindr is not currently on CRAN and includes some complex features for analyzing colorblind safeness that are not necessary for using the Okabe-Ito palette. Additionally, colorblindr was developed prior to R 4.0.0, which set Okabe-Ito as the default discrete color palette. ggokabeito thus has fewer overall dependencies but a strong one on R 4.0.0 or greater.

Code of Conduct

Please note that the ggokabeito project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Metadata

Version

0.1.0

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