The goal of ishihara is to create an Ishihara test, which can help assess colourblindness.
There are a few implementations of this test around the web, but I haven’t seen one that worked for R, so here is my crack at implementing it.
Note that this is a work in progress, don’t use it for proper testing.
The development version from GitHub with:
# install.packages("devtools")
devtools::install_github("njtierney/ishihara")
I had an idea on how I could maybe create this kind of figure in R, using spatial tools. The general process is:
- Create a bunch of circles with
packcircles
- Convert that to an SF object
- Pull in a vector font from
gridfont
- Convert that font into an SF object
- Overlay the two SF objects and see where they intersect
- Plot the circles that are intersected by the text
- Change the colour palette in ggplot2 to see the impact of colourblindness
library(ishihara)
## basic example code
library(ggplot2)
I’m still working through the details of the implementation and usability, but the general idea is to create something like this:
set.seed(2020-05-10)
cb_1 <- ishihara_data("1")
gg_ishihara <- gg_ishihara(cb_1)
gg_ishihara
gg_ishihara + scale_fill_brewer(palette = "Dark2")
gg_ishihara + scale_fill_viridis_d()
gg_ishihara + scale_fill_manual(values = c("black", "grey90"))
gg_ishihara + scale_fill_manual(values = c("red", "green"))