Worked Examples
Validate accessible scientific figures — Visualization & Graphing
Validate accessible scientific figures — Visualization & Graphing Cross-application area: Visualization & Graphing Status: Initial scientific graphics guidance; platform-specific features not verified. Scientific objective Evaluat
Application area: Visualization & Graphing
Article classification: Technical validation / Scientific accessibility / Software quality assurance
Audience: Scientific programmers, researchers, data analysts, visualization developers, accessibility specialists, and publication editors
Reference standard: WCAG 2.2 Level AA
Technical level: Intermediate to advanced
Reference environment: Python 3, NumPy, Matplotlib, pytest, HTML, and CSS
Applies to: Static charts, interactive scientific figures, heat maps, geospatial graphics, dashboards, 3D views, and exported visualizations
Primary outputs: Accessible figure, numerical equivalent, validated contrast values, automated test receipt, and accessibility acceptance record
Estimated reading time: 12–15 minutes, excluding code execution
1. Purpose and scientific scope
Accessible scientific visualization ensures that the essential meaning of a scientific figure remains available to people with different visual, perceptual, motor, and assistive-technology requirements.
Accessibility is not achieved simply by selecting a colorblind-friendly palette or adding a generic image description. Scientific figures contain quantitative relationships, spatial information, uncertainty, statistical annotations, and visual encodings that may require multiple forms of representation.
Three independent requirements must be evaluated:
- Scientific fidelity: The figure accurately represents validated source values, transformations, uncertainty, and scientific assumptions.
- Accessibility: Essential information can be perceived, understood, and operated through appropriate alternatives and interaction methods.
- Reproducibility: The figure and its essential numerical information can be reconstructed from documented inputs and processing methods.
Core acceptance principle: A reader must be able to identify the plotted variables, units, principal relationships, comparisons, and relevant uncertainty without relying exclusively on color, visual depth, animation, or pointer-based interaction.
Accessibility compliance and scientific accuracy must be recorded as separate verification outcomes.
2. Define the scientific figure contract
Before rendering a scientific figure, document its intended meaning and the information required for independent interpretation.
| Field | Required information |
|---|---|
| Figure identifier | Stable identifier, title, and revision |
| Research question | Scientific relationship or comparison |
| Source provenance | Dataset, version, origin, license, and checksum |
| Observational unit | Sample, measurement, site, time interval, or simulation state |
| Variables | Definitions, units, types, and transformations |
| Coverage | Temporal, spatial, or categorical domain |
| Statistical methods | Estimators, grouping, uncertainty, and assumptions |
| Visual encoding | Colors, shapes, line styles, axes, and scales |
| Text alternatives | Short description and extended scientific explanation |
| Numerical equivalent | Structured data table or accessible values |
| Interaction | Keyboard controls, focus, tooltips, zoom, and motion |
| Rendering | Engine, version, output format, fonts, and dimensions |
The figure specification should be treated as a testable contract, not merely editorial metadata.
3. Accessibility requirements and standards
WCAG 2.2 defines testable accessibility requirements for web content. Scientific visualization implementations should identify which success criteria apply to their content and interactions (W3C, 2024).
| Criterion | Level | Application |
|---|---|---|
| 1.1.1 Non-text Content | A | Text alternatives for informational figures |
| 1.3.1 Info and Relationships | A | Semantic tables, headings, labels, and relationships |
| 1.4.1 Use of Color | A | Information is not conveyed by color alone |
| 1.4.3 Contrast (Minimum) | AA | Readable text and text within images |
| 1.4.4 Resize Text | AA | Text remains usable when enlarged |
| 1.4.10 Reflow | AA | Applicable content remains usable at narrow effective viewports |
| 1.4.11 Non-text Contrast | AA | Essential graphical elements and control states |
| 2.1.1 Keyboard | A | Interactive operations without a pointer |
| 2.2.2 Pause, Stop, Hide | A | Applicable moving or automatically updating content |
| 2.4.7 Focus Visible | AA | Visible keyboard focus |
| 2.4.11 Focus Not Obscured (Minimum) | AA | Focused interface components remain visible |
| 4.1.2 Name, Role, Value | A | Programmatically identifiable interactive controls |
This list highlights commonly relevant criteria, rather than replacing a complete WCAG conformance evaluation.
4. Mathematical evaluation of contrast
4.1 Relative luminance
WCAG contrast calculations use relative luminance derived from linearized sRGB color components.
For an sRGB component normalized to the interval [0,1]:
if C_srgb <= 0.04045:
C_linear = C_srgb / 12.92
else:
C_linear =
((C_srgb + 0.055) / 1.055)^2.4
The relative luminance is:
L = 0.2126R + 0.7152G + 0.0722B
Here, R, G, and B are the linearized components, not the original gamma-encoded channel values.
4.2 Contrast ratio
The contrast ratio between two colors is:
Contrast = (L_lighter + 0.05)
/ (L_darker + 0.05)
Possible ratios range from 1:1 to 21:1.
Relevant WCAG 2.2 Level AA thresholds include:
| Content | Threshold |
|---|---|
| Normal text | 4.5:1 |
| Large text | 3:1 |
| Essential non-text graphical objects | 3:1 against relevant adjacent colors, subject to exceptions |
| Applicable interface component information | 3:1 against relevant adjacent colors, subject to exceptions |
Contrast thresholds do not mean every pixel of a complex figure must independently meet 3:1. Apply the relevant criterion to information necessary for understanding the graphic, including meaningful boundaries, marks, and interface states.
5. Implement a numerical contrast checker
The following Python code calculates WCAG-style contrast ratios for six-digit hexadecimal sRGB colors.
5.1 Prepare the environment
mkdir sc-accessibility-validation
cd sc-accessibility-validation
python3 -m venv .venv
source .venv/bin/activate
python -m pip install numpy matplotlib pytest
python --version
python -m pip freeze > requirements-lock.txt
5.2 Create the contrast module
Save as contrast.py.
def srgb_to_linear(channel):
if channel <= 0.04045:
return channel / 12.92
return (
(channel + 0.055) / 1.055
) ** 2.4
def relative_luminance(hex_color):
color = hex_color.lstrip("#")
if len(color) != 6:
raise ValueError("Expected six-digit hex")
try:
channels = [
int(color[i:i + 2], 16) / 255
for i in (0, 2, 4)
]
except ValueError as exc:
raise ValueError(
"Invalid hexadecimal color"
) from exc
r, g, b = [
srgb_to_linear(c)
for c in channels
]
return (
0.2126 * r +
0.7152 * g +
0.0722 * b
)
def contrast_ratio(foreground, background):
a = relative_luminance(foreground)
b = relative_luminance(background)
lighter = max(a, b)
darker = min(a, b)
return (
(lighter + 0.05) /
(darker + 0.05)
)
def minimum_contrast(
foreground,
background,
threshold=4.5
):
return (
contrast_ratio(
foreground,
background
) >= threshold
)
if __name__ == "__main__":
print(
"Black/white:",
contrast_ratio("#000000", "#ffffff")
)
print(
"Gray/white:",
contrast_ratio("#777777", "#ffffff")
)
5.3 Expected output
Black/white: 21.0
Gray/white: approximately 4.48
The gray-on-white combination is below the normal-text threshold of 4.5:1. Rounding a measured ratio upward must not be used to justify an otherwise failing contrast result.
This function applies to opaque six-digit sRGB colors. Transparency, gradients, antialiasing, overlapping objects, and rendered backgrounds require additional evaluation.
6. Automated contrast unit tests
Save as test_contrast.py.
import pytest
from contrast import (
contrast_ratio,
minimum_contrast
)
def test_black_white():
assert contrast_ratio(
"#000000", "#ffffff"
) == pytest.approx(21.0)
def test_identical_colors():
assert contrast_ratio(
"#ffffff", "#ffffff"
) == pytest.approx(1.0)
def test_normal_text_pass():
assert minimum_contrast(
"#000000",
"#ffffff",
threshold=4.5
)
def test_low_contrast_fails():
assert not minimum_contrast(
"#777777",
"#ffffff",
threshold=4.5
)
def test_color_order_independent():
forward = contrast_ratio(
"#174a67",
"#ffffff"
)
reverse = contrast_ratio(
"#ffffff",
"#174a67"
)
assert forward == pytest.approx(reverse)
def test_invalid_color_rejected():
with pytest.raises(ValueError):
contrast_ratio(
"#xyzxyz",
"#ffffff"
)
Execute:
python -m pytest -v test_contrast.py
Six tests are defined. Passing results must be established through execution. Even when all six pass, the test suite does not certify the visual accessibility of a complete rendered figure.
7. Construct a reproducible scientific fixture
The following synthetic example compares control and treatment values at three time points.
| Time (days) | Control (units) | Treatment (units) | Difference (units) |
|---|---|---|---|
| 0 | 10 | 10 | 0 |
| 7 | 11 | 14 | 3 |
| 14 | 12 | 17 | 5 |
Expected numerical relationships:
Treatment change:
17 - 10 = 7 units
Control change:
12 - 10 = 2 units
Between-group difference at day 14:
17 - 12 = 5 units
These are descriptive differences only. The fixture provides no replicate-level variation, sampling uncertainty, or inferential statistical results. It must not be used to claim treatment effectiveness or statistical significance.
8. Generate a visually distinguishable figure
The rendering example combines line styles, marker shapes, direct series labels through the legend, and explicitly identified axis units.
Save as render_accessible_figure.py.
import hashlib
import json
from pathlib import Path
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
OUTPUT = Path("figure-output")
OUTPUT.mkdir(exist_ok=True)
days = np.array([0, 7, 14])
control = np.array([10, 11, 12])
treatment = np.array([10, 14, 17])
difference = treatment - control
np.testing.assert_array_equal(
difference,
np.array([0, 3, 5])
)
assert treatment[-1] - treatment[0] == 7
assert control[-1] - control[0] == 2
fig, ax = plt.subplots(
figsize=(8, 5),
dpi=200
)
control_line, = ax.plot(
days,
control,
color="#174a67",
marker="o",
linestyle="-",
linewidth=2.5,
markersize=8,
label="Control"
)
treatment_line, = ax.plot(
days,
treatment,
color="#a43b28",
marker="s",
linestyle="--",
linewidth=2.5,
markersize=8,
label="Treatment"
)
ax.set_xlabel("Time (days)")
ax.set_ylabel(
"Measurement (synthetic units)"
)
ax.set_xticks(days)
ax.set_ylim(0, 20)
ax.legend()
ax.grid(axis="y", alpha=0.2)
# Validate actual plotted values.
np.testing.assert_array_equal(
control_line.get_ydata(),
control
)
np.testing.assert_array_equal(
treatment_line.get_ydata(),
treatment
)
assert control_line.get_linestyle() == "-"
assert treatment_line.get_linestyle() == "--"
fig.tight_layout()
png = OUTPUT / "synthetic-comparison.png"
svg = OUTPUT / "synthetic-comparison.svg"
fig.savefig(png, dpi=200)
fig.savefig(svg)
plt.close(fig)
def sha256(path):
return hashlib.sha256(
path.read_bytes()
).hexdigest()
receipt = {
"fixture": "synthetic_treatment_control",
"observation_count": 3,
"numeric_validation": "pass",
"plot_data_validation": "pass",
"grayscale_review": "not_tested",
"contrast_review": "not_tested",
"screen_reader_review": "not_tested",
"scientific_review": "not_tested",
"png_sha256": sha256(png),
"svg_sha256": sha256(svg)
}
(OUTPUT / "receipt.json").write_text(
json.dumps(receipt, indent=2),
encoding="utf-8"
)
print("Numerical fixture checks passed")
Execute:
python render_accessible_figure.py
The script creates PNG and SVG versions and records their hashes. The numerical assertions test the values passed to Matplotlib, not visual WCAG conformance.
9. Provide semantic HTML and equivalent numerical content
An exported scientific image should be accompanied by a concise alternative description and, for complex graphics, more detailed information available in accessible content (W3C WAI, n.d.).
The following HTML is an example of a publication structure, intended to be integrated into an appropriately secured page.
<figure>
<img
src="synthetic-comparison.png"
alt="Line chart comparing synthetic control
and treatment values over 14 days.
Detailed values follow in the data table."
aria-describedby="figure-description">
<figcaption>
Figure 1. Synthetic control and treatment
comparison over a 14-day interval.
No inferential statistical conclusion is
supported by this fixture.
</figcaption>
</figure>
<section id="figure-description">
<h3>Detailed figure description</h3>
<p>
Both series begin at 10 units on day 0.
At day 7, control is 11 and treatment is 14.
At day 14, control is 12 and treatment is 17.
The final between-group difference is 5 units.
The values are synthetic.
</p>
</section>
<table>
<caption>
Numerical values for Figure 1
</caption>
<thead>
<tr>
<th scope="col">Day</th>
<th scope="col">Control</th>
<th scope="col">Treatment</th>
</tr>
</thead>
<tbody>
<tr><th scope="row">0</th><td>10</td><td>10</td></tr>
<tr><th scope="row">7</th><td>11</td><td>14</td></tr>
<tr><th scope="row">14</th><td>12</td><td>17</td></tr>
</tbody>
</table>
The short description identifies the visualization and directs readers to the detailed numerical equivalent. The extended description communicates the main trend and important values.
Accessible relationships should be expressed through real HTML semantics, not visual spacing or tables represented only as images.
10. Test color independence
Colors may improve chart readability, but they must not be the sole means of identifying essential scientific information.
Recommended redundant encodings include:
- Solid and dashed lines.
- Circle, square, and triangle markers.
- Direct labels.
- Distinct line textures or patterns.
- Annotated thresholds and reference values.
- Accompanying numerical tables.
Use grayscale inspection and appropriate color-vision simulations as supporting tests. Do not treat simulations as a complete substitute for evaluation by people with different visual needs.
Pass condition: Readers can identify each essential series, category, or relationship without relying on color differences.
11. Validate interactive figures
Interactive scientific graphics require additional testing beyond static figure inspection.
| Interaction | Required result |
|---|---|
| Keyboard navigation | Essential controls are operable without a pointer |
| Focus | Logical order and visible focus indication |
| Data inspection | Important values remain available without hover-only tooltips |
| Zoom and pan | Essential information remains accessible or has an equivalent alternative |
| Legend interaction | Visible and hidden series states can be identified |
| Animation | Applicable pause, stop, or hide controls and meaningful time labels |
| Responsive layout | Labels, values, and essential controls remain usable when resized |
| Assistive technology | Figure purpose and essential values can be retrieved |
Test with actual browsers and assistive technologies. Automated scanning cannot establish whether a scientific graphic communicates its numerical meaning correctly to a screen-reader user.
12. Scientific integrity and uncertainty
Accessibility improvements must not alter the scientific meaning of the figure.
Verify that:
- Plotted coordinates match source values.
- Axis scales and units are correct.
- Logarithmic transformations are disclosed.
- Category and temporal ordering are valid.
- Missing observations remain identifiable.
- Fitted curves and interpolated points are labeled.
- Statistical significance is not inferred from appearance alone.
- Uncertainty intervals are correctly defined.
- Figure descriptions agree with the underlying data.
For two reported values A and B, a descriptive difference is:
Delta = A - B
In the synthetic example:
Delta_day14 = 17 - 12 = 5
This difference alone cannot establish statistical significance. Inferential analysis would require the relevant study design, sampling structure, and uncertainty information.
13. Validation and evidence workflow
A reproducible accessibility-validation workflow should follow the sequence below.
- Register the figure: Record its identifier, revision, source data, and intended scientific purpose.
- Verify numerical values: Recompute plotted coordinates and descriptive summaries from source data.
- Inspect visual encodings: Confirm axes, labels, colors, markers, line styles, and annotations.
- Measure contrast: Test required text and graphical elements against applicable thresholds.
- Verify color independence: Review grayscale and suitable alternative perception modes.
- Inspect text equivalents: Compare alternative descriptions and numerical tables against the figure.
- Test interaction: Perform keyboard and focus testing when the figure is interactive.
- Test assistive technology: Review essential values and relationships in a supported screen-reader/browser combination.
- Test export: Inspect raster, vector, and HTML outputs independently.
- Repeat independently: Reproduce the required numerical and graphical properties from archived inputs.
- Record review: Document the reviewer, evidence, outcome, limitations, and required corrections.
14. Scientific and accessibility acceptance matrix
| Test | Pass condition | Evidence |
|---|---|---|
| Data integrity | Source values and units reconcile with plotted data | Numerical test receipt |
| Contrast | Applicable WCAG thresholds are met | Contrast measurements |
| Color independence | Essential information is not conveyed through color alone | Grayscale and encoding review |
| Text alternatives | Figure purpose and essential findings are described accurately | Text review |
| Numerical equivalents | Required values and units are accessible | Data-table reconciliation |
| Keyboard | Essential controls work without pointer input | Manual keyboard test |
| Assistive technology | Scientific relationships can be retrieved and understood | Screen-reader review |
| Responsive behavior | Essential information remains usable under applicable resizing conditions | Browser test |
| Export | Published artifacts preserve scientific and accessible content | Artifact inspection |
| Reproducibility | Archived inputs regenerate required results | Independent execution |
| Scientific review | Interpretation does not exceed the evidence | Reviewer assessment |
Decision rule: Record Pass, Fail, or Not Tested for each applicable requirement. Do not classify an entire figure or visualization component as conformant when mandatory criteria remain failed or untested.
15. Reproducibility and evidence packaging
The evidence package should contain:
- Authoritative source data or permitted immutable references.
- Processed numerical tables with identifiers and units.
- Rendering scripts or declarative specifications.
- Dependency versions and runtime identification.
- Figure specifications and graphical encodings.
- Rendered PNG, SVG, or other supported artifacts.
- Short and extended accessible descriptions.
- Accessible structured numerical data.
- Contrast and graphical distinguishability results.
- Keyboard and assistive-technology review records.
- Artifact checksums and manifest.
- Reviewer identity, date, outcome, and outstanding limitations.
Byte-for-byte image hashes may change across fonts, operating systems, rendering engines, and dependency versions. Record actual artifact hashes for integrity, while separately validating numerical consistency and required graphical properties.
16. Sustainable Catalyst integration responsibilities
The following responsibilities describe an intended cross-application workflow. Actual implementation must be verified against deployed software.
| Application | Intended responsibility |
|---|---|
| Library | Source data, provenance, rights, and accessible source documentation |
| Research Lab | Scientific validation and numerical comparisons |
| Workbench | Reproducible figure computation and test execution where supported |
| Visualization & Graphing | Chart presentation, semantics, interactive controls, and export accessibility |
| Site Intelligence | Accessible spatial and geospatial interpretations where implemented |
| Research | Publication figures, captions, structured numerical alternatives, and review evidence |
| Workspace | Accessibility reviews, ownership, acceptance status, and corrective actions |
Each implemented renderer should be evaluated separately. A renderer passing numerical tests does not imply that an exported HTML dashboard or publication page passes accessibility testing.
17. Source audit and platform acceptance
Before certifying a Sustainable Catalyst graphics component as accessible, record:
- Owning repository and source-code revision.
- Installed renderer and application versions.
- Supported output formats and interfaces.
- Source-to-figure numerical test results.
- Rendered contrast calculations and visual review.
- Accessible descriptions and table equivalence.
- Keyboard and screen-reader acceptance evidence.
- Applicable browser and operating-system combinations.
- Known limitations and unresolved failures.
- Reviewer, test date, and evidence artifacts.
Accessibility certification requires verified implementation behavior, not merely documentation, an installed rendering library, or passing isolated Python assertions.
18. Technical references
- World Wide Web Consortium (W3C) (2024). Web Content Accessibility Guidelines (WCAG) 2.2. Available at: https://www.w3.org/TR/WCAG22/.
- W3C Web Accessibility Initiative (n.d.). Complex Images. Available at: https://www.w3.org/WAI/tutorials/images/complex/.
- W3C Web Accessibility Initiative (n.d.). Understanding Success Criterion 1.4.11: Non-text Contrast. Available at: W3C Understanding Document.
- W3C Web Accessibility Initiative (n.d.). Understanding Success Criterion 1.4.1: Use of Color. Available at: W3C Understanding Document.
- Harris, C.R. et al. (2020). ‘Array programming with NumPy’, Nature, 585, pp. 357–362. Available at: https://doi.org/10.1038/s41586-020-2649-2.
- Matplotlib Development Team (n.d.). Matplotlib Documentation. Available at: https://matplotlib.org/stable/.
- pytest Development Team (n.d.). pytest Documentation. Available at: https://docs.pytest.org/en/stable/.
19. Completion and verification record
| Field | Required record |
|---|---|
| Figure ID | Identifier and revision |
| Source data | Dataset version and integrity reference |
| Numerical validation | Pass, Fail, or Not Tested |
| Color independence | Pass, Fail, or Not Tested |
| Contrast | Pass, Fail, or Not Tested |
| Text alternatives | Pass, Fail, or Not Tested |
| Numerical equivalent | Pass, Fail, or Not Tested |
| Keyboard accessibility | Pass, Fail, or Not Tested |
| Assistive technology | Pass, Fail, or Not Tested |
| Export verification | Pass, Fail, or Not Tested |
| Reproducibility | Pass, Fail, or Not Tested |
| Scientific review | Pass, Fail, or Not Tested |
| Reviewer | Actual reviewer and review date |
| Evidence | Code, source data, screenshots, receipts, and hashes |
| Outstanding limitations | Unresolved accessibility or scientific concerns |
Completion criterion: A scientific figure may be accepted when its quantitative meaning is validated, applicable accessibility requirements have been tested, essential information is provided through suitable accessible alternatives, and the results can be reproduced from preserved evidence.
Scientific limitation: Accessible and reproducible visualization cannot remedy biased measurements, invalid models, inappropriate sampling, or unsupported inference. Scientific validation, accessibility validation, and software verification must remain independently documented.
Current implementation status: Technical accessibility-validation methodology and reproducible synthetic examples documented. No specific Sustainable Catalyst renderer, interactive visualization component, or production export has been certified without actual source review, executed accessibility testing, and release-specific acceptance evidence.
