These slides test various approaches to increasing the accessibility of plots in xaringan slides. The code for the plot is presented in a later slide. The test on the next slide uses the slide heading as the plot title. The code is hidden and the `fig.alt` chunk option is used to add alt text to the plot. The data in the plot is printed in a visually hidden block after the image. --- # Lemur Population <img src="index_files/figure-html/lemur-pop-1.svg" title="Line chart of a simulated lemur population from 2000 to 2020." alt="Line chart of a simulated lemur population from 2000 to 2020." width="100%" /> .visually-hidden[ The line chart contains the following data: | year| population| |-----:|----------:| | 2,000| 548| | 2,001| 509| | 2,002| 522| | 2,003| 591| | 2,004| 620| | 2,005| 668| | 2,006| 682| | 2,007| 641| | 2,008| 716| | 2,009| 763| | 2,010| 716| | 2,011| 781| | 2,012| 752| | 2,013| 857| | 2,014| 879| | 2,015| 922| | 2,016| 870| | 2,017| 944| | 2,018| 942| | 2,019| 938| | 2,020| 958| ] <style> /* https://github.com/h5bp/main.css/issues/12#issuecomment-451965809 */ .visually-hidden { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); -webkit-clip-path: inset(50%); clip-path: inset(50%); border: 0; white-space: nowrap; } </style> --- The test on the next slide uses the plot as the slide's background image. The visually hidden block is used again with a table containing the data. --- background-image: url(index_files/figure-html/lemur-pop-plot-1.svg) background-size: 90% .visually-hidden[ This slide shows a line chart of a simulated lemur population from 2000 to 2020. | year| population| |-----:|----------:| | 2,000| 548| | 2,001| 509| | 2,002| 522| | 2,003| 591| | 2,004| 620| | 2,005| 668| | 2,006| 682| | 2,007| 641| | 2,008| 716| | 2,009| 763| | 2,010| 716| | 2,011| 781| | 2,012| 752| | 2,013| 857| | 2,014| 879| | 2,015| 922| | 2,016| 870| | 2,017| 944| | 2,018| 942| | 2,019| 938| | 2,020| 958| ] --- I tested directly embedding the SVG file here, but it very much did not work. --- # Code for the plot ```r set.seed(4242) lemurs <- tibble::tibble( year = 2000:2020, population = 500 + (25 * (year - 2000)) + floor(runif(length(year), -50, 50)) ) ``` ```r library(ggplot2) ggplot(lemurs) + aes(year, population) + geom_line(size = 2) + labs(x = NULL, y = NULL, title = "Lemur Population") + theme_xaringan() ```