# Accessibility

Accessibility legislation means that all content published on public sector websites, including charts, must meet the level A and AA success criterion in the Web Content Accessibility Guidelines 2.1.

## Resources

The Government Analysis Function has published a variety of resources for producing accessible data visualisations:

- Charts Checklist
- Charts Guidance
- Colours Guidance
- Data Visualisation e-Learning (in particular the Accessibility and Colour module)

afcharts has been developed following advice in the above guidance, however, using afcharts does not guarantee accessibility. afcharts should therefore be used in conjunction with this guidance.

## Accessibility of charts using afcharts

By applying `theme_af` to ggplot2 plots, the following best practice is followed:

- Plot background is white.

- Axis lines and ticks are light grey (#595959). By default, only the x axis is shown but these can be controlled using the `axis` and `ticks` arguments.

- Grid lines are light grey (#595959) and kept to a minimum; by default only major y axis lines are shown, but this can be controlled using the `grid` argument.

- Text is black, uses a Sans Serif font and is size 12 by default. Text size can be controlled using the `base_size` argument.

- All text is horizontal.

- Line thickness is relative to font size.

afcharts provides colour palettes as set out by the Government Analysis Function Colour Guidance. These palettes have been developed to meet the Web Content Accessibility Guidelines 2.1 for graphical objects and can be applied to charts by using one of the four colour/fill functions:

- `scale_colour_discrete_af()`
- `scale_fill_discrete_af()`
- `scale_colour_continuous_af()`
- `scale_fill_continuous_af()`

More information on afcharts colours can be found at `vignette("colours")`.

## Other accessibility considerations

Using afcharts does not guarantee accessibility. The Government Analysis Function chart guidance contains detailed information on other considerations that should be made. Not all of these are repeated here, but we think the following are a good place to start:

- Consider what type of chart is best to convey your message. Keep it as simple as possible.

- Plot titles should be provided in the body of the page, not embedded within the image of the plot. This does pose the risk of the plot image being re-shared without the title and losing context, however it is usually preferable to prioritise accessibility.

- All plots must have alt text (this may be in the code behind an image of the plot, but could also be a table of data or a text description of the message the chart is presenting).

- Take great care if using a stacked bar chart. Keep the number of categories to a minimum, and carefully consider the order of categories and bars.

- If horizontal text is difficult to read (for example, if axis labels are overlapping), consider a different chart orientation or type.

- If using a bar chart, the gap between bars should be narrower than the width of a single bar. The R Graphics cookbook describes how to do this.

- Use commas as thousands separators in axis labels or text annotations.

- Ask for feedback from colleagues and users.