Install: pip install a11yviz — a11yviz on PyPI
matplotlib transforms
Composable transforms for matplotlib figures.
| Function | Description |
|---|---|
theme(level: str = 'AA', dark: bool = False) |
Apply WCAG-aligned matplotlib rcParams within a with block. |
plotly transforms
Layout and styling for plotly figures.
| Function | Description |
|---|---|
layout(fig, level: str = 'AA', palette: str | None = 'dark2_8') |
Apply accessible layout to a plotly Figure. |
Alt text
Attach, scaffold, or LLM-draft screen-reader descriptions.
| Function | Description |
|---|---|
alt_text(fig, text: str) |
Set an alt-text description for a Figure. |
alt_template(fig: Any) -> str |
Generate an alt-text template for a matplotlib or plotly figure. |
describe(fig, backend: Callable[[dict], str], attach: bool = True) |
Generate alt text for a figure via a user-supplied backend. |
Palettes
Discrete, diverging, and sequential palettes with WCAG metadata.
| Function | Description |
|---|---|
palette(name: str = 'dark2_8', n: int | None = None, bg: str | None = None) -> list[str] |
Return hex codes for a color-vision-aware categorical palette. |
palette_div(name: str = 'rdbu') -> dict |
Return {"low", "mid", "high"} anchors for a diverging gradient. |
palette_seq(name: str = 'cividis', n: int | None = None) |
Return a sequential gradient spec, or n interpolated hex codes. |
palette_info(name: str = 'dark2_8') -> dict |
Return source spec, resolved colors, and WCAG metadata for a palette. |
palette_list(type: str | None = None) -> list[dict] |
List discrete, diverging, and sequential palettes in one table. |
show_palette(name: str = 'dark2_8', bg: str = '#ffffff', level: str = 'AA') |
Render swatches of a built-in palette with contrast overlay. |
Audits and checks
Multi-criterion figure audit, rubric, and single-aspect checks.
| Function | Description |
|---|---|
audit(fig, level: str = 'AA') -> list[dict] |
Audit a figure against accessibility standards. |
rubric(level: str | None = None) -> list[dict] |
Return the chart-relevant subset of WCAG 2.1 success criteria. |
check_headings(path, min_chars: int = 3) -> list[dict] |
Scan a file for three heading defects: |
check_palette(colors, bg='#ffffff', level: str = 'AA', alpha: float = 1.0) -> list[dict] |
Check pairwise color-vs-background contrast against WCAG thresholds. |
check_palette_size(n: int, max: int = 7) -> dict |
Return a status dict noting whether n exceeds max. |
check_readability(text) -> dict |
Compute Flesch-Kincaid Grade Level and Reading Ease for prose. |
check_separability(colors, min_ratio: float = 3.0) -> list[dict] |
Flag color pairs below the WCAG 2.1 Success Criterion 1.4.11 contrast threshold. |
plotly_sequences(bg: str = '#ffffff', level: str = 'AA') -> list[dict] |
WCAG contrast statistics for each plotly built-in color sequence. |
Wrappers and utilities
One-shot helpers and resource paths.
| Function | Description |
|---|---|
make_a11y(fig, level: str = 'AA', palette: str | None = 'dark2_8', alt: str | None = None) |
Apply layout + (optional) alt text in one call. |
alpha_presets() -> dict |
Return alpha values for common chart roles. |
text_spacing_ratios() -> dict |
Return the spacing ratios specified in WCAG Success Criterion 1.4.12 (Text Spacing). |
css_path() -> pathlib._local.Path |
Return the filesystem path to a11yviz.css. |
wcag_url(criterion: str) -> str |
Return the deep link to the W3C WCAG 2.1 entry for one success criterion. |