Nicola Rennie
Consultancy
Training
R Community
Choose a font: fonts.google.com
Choose a font: fonts.google.com
Load it into R:
Let’s make an example plot to demonstrate…
name | n |
---|---|
Crowned lemur | 2094 |
Ring-tailed lemur | 7490 |
Gray mouse lemur | 12275 |
Image: Unsplash
Sans serif
Serif
Monospace
Sans serif: Does it pass the 1Il test?
Serif: Does it pass the 1Il test?
Monospace: Does it pass the 1Il test?
Calibri
Source Sans Pro
Noto Sans
Raleway
Colour of geoms (mapped to variables in aes()
)
Colour of geoms (not mapped in aes()
)
theme()
elements e.g. background colour
scale_*_brewer()
: colorbrewer2.org
Colour palette packages: github.com/EmilHvitfeldt/paletteer
Defining your own colours
Check if the palette package has a colorblindfriendly
argument
display_carto_all(colorblind_friendly = TRUE)
from {rcartocolor}.Perform your own checks…
name n tolerance ncp ndcp min_dist mean_dist max_dist
1 normal 3 44.33725 3 3 44.337246 48.67622 55.30187
2 deuteranopia 3 44.33725 3 1 25.872723 34.57704 50.79886
3 protanopia 3 44.33725 3 1 9.345734 31.53395 46.54013
4 tritanopia 3 44.33725 3 2 41.560179 50.49023 60.86996
Text providing a description of what an image contains for people who use screen readers.
Recent RLadies New York Talk: https://lizharedogs.github.io/RLadiesNYAltText/#1
Link: medium.com/nightingale/writing-alt-text-for-data-visualization-2a218ef43f81
A plot of number of lemurs per species.
A bar chart titled Lemurs at Duke Lemur Center. On the x-axis three species of lemurs are shown including the Crowned lemur, Gray mouse lemur, and Ring-tailed lemur. On the y-axis the count of the number of each species is shown. The number of lemurs ranges from just under 2500 for Crowned lemurs, to almost 12500 for Gray mouse lemurs. The number of Crowned lemurs is significantly lower than the other two species shown.
g <- ggplot(lemurs, aes(x = name, y = n, fill = name)) +
geom_col() +
labs(x = "",
y = "Number of lemurs",
title = "Lemurs at Duke Lemur Center",
alt = "A bar chart titled Lemurs at Duke Lemur Center. On the x-axis three species of lemurs are shown including the Crowned lemur, Gray mouse lemur, and Ring-tailed lemur. On the y-axis the count of the number of each species is shown. The number of lemurs ranges from just under 2500 for Crowned lemurs, to almost 12500 for Gray mouse lemurs. The number of Crowned lemurs is significantly lower than the other two species shown.")
Extract the alt text:
[1] "A bar chart titled Lemurs at Duke Lemur Center. On the x-axis three species of lemurs are shown including the Crowned lemur, Gray mouse lemur, and Ring-tailed lemur. On the y-axis the count of the number of each species is shown. The number of lemurs ranges from just under 2500 for Crowned lemurs, to almost 12500 for Gray mouse lemurs. The number of Crowned lemurs is significantly lower than the other two species shown."
{r, fig.alt="A bar chart titled Lemurs at Duke Lemur Center. On the x-axis three species of lemurs are shown including the Crowned lemur, Gray mouse lemur, and Ring-tailed lemur. On the y-axis the count of the number of each species is shown. The number of lemurs ranges from just under 2500 for Crowned lemurs, to almost 12500 for Gray mouse lemurs. The number of Crowned lemurs is significantly lower than the other two species shown."}
{r, fig.alt=ggplot2::get_alt_text(g)}
```{r}
#| eval: false
#| fig.alt: "A bar chart titled Lemurs at Duke Lemur Center. On the x-axis three species of lemurs are shown including the Crowned lemur, Gray mouse lemur, and Ring-tailed lemur. On the y-axis the count of the number of each species is shown. The number of lemurs ranges from just under 2500 for Crowned lemurs, to almost 12500 for Gray mouse lemurs. The number of Crowned lemurs is significantly lower than the other two species shown."
#| fig-align: center
g
```
Never as good as alt text written by a human
Often misses the “what’s the point?” element of the plot
Potentially useful in interactive graphics if carefully considered
This chart has title 'Lemurs at Duke Lemur Center'.
It has x-axis '' with labels Crowned
lemur, Gray mouse
lemur and Ring-tailed
lemur.
It has y-axis 'Number of lemurs' with labels 0, 2500, 5000, 7500, 10000 and 12500.
There is a legend indicating fill is used to show name, with 3 levels:
Crowned
lemur shown as strong reddish orange fill,
Gray mouse
lemur shown as vivid yellowish green fill and
Ring-tailed
lemur shown as brilliant blue fill.
The chart is a bar chart with 3 vertical bars.
Bar 1 is centered horizontally at Crowned
lemur, and spans vertically from 0 to 2094 with fill colour strong reddish orange which maps to name = Crowned
lemur.
Bar 2 is centered horizontally at Ring-tailed
lemur, and spans vertically from 0 to 7490 with fill colour brilliant blue which maps to name = Ring-tailed
lemur.
Bar 3 is centered horizontally at Gray mouse
lemur, and spans vertically from 0 to 12275 with fill colour vivid yellowish green which maps to name = Gray mouse
lemur.
These are stacked, as sorted by name.
{ggplot2}
Accessibility
R-Ladies London