Create accessible charts
Visual Data Studio / Clarum
June 10, 2025
Pain location of a patient with arthritis
Normal vision
Protanopia (red colour blindness)
Normal vision
Deuteranopia (green colour blindness)
Calming colours feeling of security: Pink and lilac
Blue and greens
Neutral colours: Beige, greys, creams
Source: https://www.design-a11y.com/colors-autism
Example of Google Fonts that are easy to read:
Roboto
Opens Sans
Lato
Montserrat
Atkinson Hyperlegible
Lexend
{cols4all}
{coloratio}
{colorblindr}
Other packages:
{RColorBrewer}
{recolorize}
{sysfonts}
{savonliquide}
library(sysfonts)
library(showtext)
font_add_google("Lexend", family = "lexend")
showtext_auto()
font_families()
Check if the font is installed
[1] "sans" "serif" "mono" "wqy-microhei" "lexend"
datasets::penguins %>%
filter(island == "Dream") %>%
ggplot(aes(x = flipper_len, y = body_mass, colour = species)) +
geom_point() +
scale_colour_brewer(palette = "Set2") +
theme_minimal(base_family = "lexend", base_size = 14) +
ggtitle("Penguins on Dream Island")
## brand colours
library(colorblindr)
brand <- c("red", "darkgreen", "blue", "purple")
palette_plot(brand, xmargin = 0.2, ymargin = 0.8)
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
cvd_grid(palette_plot(brand, xmargin = 0.2, ymargin = 0.8,
label_size = 7, label_family = "roboto"))
library(recolorize)
brand_rgb <- t(col2rgb(brand)/ 255 )
brand_sat <- adjust_color(brand_rgb,
which_colors = c(2, 3),
saturation = 0.3,
brightness = 0.9,
plotting = TRUE)
## convert RGB colours into HEX code
brand_hex <- rgb(brand_sat)
cvd_grid(palette_plot(brand_hex, xmargin = 0.2, ymargin = 0.8,
label_size = 6, label_family = "roboto"))
Difference between colours, measured as the ratio of the relative luminance of the lighter colour to that of the darker colour.
How to check colour contrast?
{coloratio}
{savonliquide}
[1] 14.8
[1] 12.1
* The Contrast Ratio is 13.5
* The result for the AA check is : PASS
* The result for the AALarge check is : PASS
* The result for the AAA check is : PASS
* The result for the AAALarge check is : PASS
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
* The Contrast Ratio is 1.83
* The result for the AA check is : FAIL
* The result for the AALarge check is : FAIL
* The result for the AAA check is : FAIL
* The result for the AAALarge check is : FAIL
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family 'roboto' not found, will use 'sans' instead
https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/
https://cols4all.github.io/cols4all-R/index.html
https://cran.r-project.org/web/packages/recolorize/vignettes/Introduction.html
hello@ritagiordano.co.uk