https://malcolmbarrett.github.io/ggokabeito/
Colorblind-friendly, qualitative Okabe-Ito Scales for ggplot2 and ggraph
https://malcolmbarrett.github.io/ggokabeito/
Last synced: 6 months ago
JSON representation
Colorblind-friendly, qualitative Okabe-Ito Scales for ggplot2 and ggraph
- Host: GitHub
- URL: https://malcolmbarrett.github.io/ggokabeito/
- Owner: malcolmbarrett
- License: other
- Created: 2021-10-15T16:21:40.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-08T15:33:39.000Z (over 2 years ago)
- Last Synced: 2025-05-04T13:49:23.570Z (7 months ago)
- Language: R
- Homepage: https://malcolmbarrett.github.io/ggokabeito
- Size: 3.01 MB
- Stars: 51
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ggplot2 - ggokabeito - friendly, qualitative Okabe-Ito Scales for ggplot2 and ggraph (Themes and aesthetics)
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "80%",
dpi = 320,
out.width = "80%",
fig.width = 6,
fig.asp = 0.618,
fig.retina = 2,
fig.align = "center"
)
```
# ggokabeito
[](https://github.com/malcolmbarrett/ggokabeito/actions)
[](https://app.codecov.io/gh/malcolmbarrett/ggokabeito?branch=main)
[](https://CRAN.R-project.org/package=ggokabeito)
[](https://lifecycle.r-lib.org/articles/stages.html#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:
``` r
install.packages("ggokabeito")
```
You can alternatively install the development version of ggokabeito from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("malcolmbarrett/ggokabeito")
```
## Examples
```{r}
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
```{r}
# 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](https://github.com/clauswilke/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](https://malcolmbarrett.github.io/ggokabeito/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.