Accessibility: fig-alt

accessibility
alt-text
Author

Mine Çetinkaya-Rundel

Published

July 25, 2022

fig-alt

You can add alternative text to figures you create with code by adding the fig-alt chunk option, which works for Knitr, Jupyter, and Observable code chunks.

Here is an R/Knitr example.

```{r}
#| label: penguins-plot
#| warning: false
#| fig-alt: |
#|   Scatterplot of penguin bill depth vs. length, colored by species.
#|   The relationship is positive for each of the three species.

library(tidyverse)
library(palmerpenguins)
library(colorblindr)

ggplot(penguins, 
       aes(x = bill_length_mm, y = bill_depth_mm, color = species)) +
  geom_point() +
  scale_color_OkabeIto()
```

Scatterplot of penguin bill depth vs. length, colored by species. The relationship is positive for each of the three species.

The resulting HTML is shown below. The alternative (alt) text is accessible to screen readers.

<img src="index_files/figure-html/penguins-plot-1.png" class="img-fluid" alt="Scatterplot of penguin bill depth vs. length, colored by species. The relationship is positive for each of the three species." width="672">

Learn more

Quarto chunk options:

Guidance for writing alt text: