Worked Examples
Develop and test accessible scientific figures — Visualization & Graphing
Develop and test accessible scientific figures — Visualization & Graphing Cross-application area: Visualization & Graphing Status: Initial scientific graphics guidance; platform-specific features not verified. Rendering contract o
scientific software engineers, platform maintainers, QA engineers,
and accessibility reviewers
Cross-application area: Visualization & Graphing
Article type: Developer implementation and testing guide
Status: Proposed engineering guidance — implementation
verification pending
Primary concern: Scientific correctness, accessibility,
reproducibility, secure rendering, and publication integrity
1. Engineering Objective
Implement a reusable scientific-figure pipeline that converts verified
datasets and computational results into accessible visualizations without
altering their scientific meaning.
The visualization system must separate authoritative scientific data
from rendering instructions. Rendering libraries should consume validated
data and a versioned figure specification rather than independently
modifying measurements or performing undocumented transformations.
Core engineering invariants:
- Scientific fidelity: Every rendered mark must correspond
to a validated source value or explicitly documented transformation. - Accessibility: Essential quantitative comparisons
must be recoverable without relying on color alone or inaccessible
interaction mechanisms. - Reproducibility: The same immutable input, transformation
specification, and pinned software environment must reproduce
equivalent scientific results. - Traceability: Each figure must reference the dataset
version, computational result, rendering specification, and relevant
provenance records. - Security: Untrusted data, labels, annotations, SVG
content, and rendering parameters must not permit script execution,
unauthorized data disclosure, or unsafe resource access. - Export consistency: Static and interactive outputs
must preserve numerical relationships, uncertainty semantics,
units, and accessible supporting information.
Required result: A figure is a verifiable presentation
of scientific evidence, not an independent or undocumented analytical
artifact.
2. Reference Architecture
The proposed implementation consists of seven logical stages.
These are architectural responsibilities, not confirmation of
existing deployed services.
- Source resolution: Resolve an authorized, versioned
dataset or verified computational artifact. - Schema validation: Validate data types, units,
missing values, coordinate systems, uncertainty fields,
and source references. - Scientific transformation: Apply explicitly declared
filtering, aggregation, normalization, or analytical operations. - Figure specification: Construct a typed,
renderer-independent specification defining visual encodings,
axes, legends, annotations, and uncertainty semantics. - Rendering: Generate interactive or static output
through an approved, versioned rendering adapter. - Accessibility representation: Generate or associate
descriptions, accessible data tables, and keyboard-accessible
interactions where applicable. - Verification and publication: Validate the generated
artifacts, record test evidence, and apply publication authorization.
2.1 Separation of Responsibilities
| Component | Responsibility | Prohibited Behavior |
|---|---|---|
| Data adapter | Resolve authoritative data and metadata. | Silently substitute or modify source values. |
| Transformation engine | Execute documented numerical operations. | Apply undocumented statistical calculations. |
| Figure specification validator | Validate encodings, units, axes, and uncertainty. | Accept ambiguous dimensional or unit mappings. |
| Rendering adapter | Translate an approved specification into graphics. | Invent measurements or uncertainty semantics. |
| Accessibility adapter | Provide equivalent information and accessible interaction. | Claim accessibility solely because alt text exists. |
| Export service | Generate validated distributable artifacts. | Remove essential data context without disclosure. |
| Publication controller | Enforce review, ownership, rights, and approval rules. | Publish an unapproved or unverified scientific claim. |
3. Figure Data Contract
Every renderer should consume a validated figure specification.
Use a versioned schema shared across backend services, frontend
applications, and export workers.
The following JSON illustrates a minimal proposed contract.
It is not a currently verified Sustainable Catalyst API schema.
{
"schema_version": "1.0.0",
"figure_id": "fig-example-001",
"source": {
"artifact_id": "dataset-example-001",
"version": "1",
"sha256": "REPLACE_WITH_VERIFIED_SHA256"
},
"figure_type": "line",
"title": "Observed Carbon Removal by Year",
"series": [
{
"id": "observed-removal",
"label": "Measured removal",
"x": [2024, 2025, 2026],
"y": [0.8, 1.2, 1.5],
"missing": [false, false, false],
"unit": "t CO2 / ha",
"kind": "observed",
"uncertainty": {
"type": "confidence_interval",
"confidence_level": 0.95,
"lower": [0.6, 0.9, 1.1],
"upper": [1.0, 1.5, 1.9]
}
}
],
"axes": {
"x": {
"label": "Year",
"type": "time",
"temporal_granularity": "year",
"scale": "linear"
},
"y": {
"label": "Carbon removal",
"unit": "t CO2 / ha",
"scale": "linear"
}
},
"accessibility": {
"title": "Observed carbon removal by year",
"description": "Measured values increase from 0.8 to 1.5 tonnes of CO2 per hectare over the three annual observations. Confidence intervals are shown.",
"table_required": true,
"color_independent_encoding": true
},
"render": {
"engine": "plotly",
"theme": "accessible",
"interactive": true
}
}
Important: The values in this example are synthetic.
They are not experimental results, verified carbon-removal estimates,
or data from the Wexford research project.
3.1 Required Validation Rules
- Reject unsupported schema versions.
- Reject mismatched series lengths.
- Reject nonnumeric values in numeric series unless explicitly represented as missing.
- Handle NaN and infinity through an explicit policy rather than silently serializing or plotting them.
- Validate unit compatibility across shared axes.
- Validate temporal reference and granularity.
- Require coordinate reference information for spatial datasets where relevant.
- Require lower and upper bounds to align with corresponding observations.
- Reject uncertainty bounds that are internally inconsistent.
- Require an explicit uncertainty definition, including confidence level when applicable.
- Validate transformations and filter parameters against approved operations.
- Resolve source references only after authorization checks.
- Enforce limits for data size, nesting depth, annotation length, and rendering complexity.
3.2 Do Not Infer Scientific Meaning
A renderer must not infer that a shaded region represents a confidence
interval, prediction interval, standard deviation, or measurement range
simply because upper and lower bounds are supplied.
Similarly, a third numerical field must not automatically be interpreted
as a physical Z coordinate, altitude, uncertainty, or time dimension.
Implementation rule: Scientific semantics must be
explicitly declared and validated before visual encoding.
4. Backend Validation Implementation
The validation layer should execute before figure generation.
The following Python example demonstrates basic numeric consistency
checks using a proposed contract.
import math
def validate_numeric_series(series):
x = series["x"]
y = series["y"]
missing = series["missing"]
if not (len(x) == len(y) == len(missing)):
raise ValueError("Series lengths do not match")
for index, value in enumerate(y):
if missing[index]:
if value is not None:
raise ValueError(
"Missing observations must use null values"
)
continue
if isinstance(value, bool):
raise ValueError("Boolean is not a numeric measurement")
if not isinstance(value, (int, float)):
raise ValueError("Invalid numeric data type")
if not math.isfinite(value):
raise ValueError("Non-finite numeric value")
uncertainty = series.get("uncertainty")
if uncertainty:
lower = uncertainty["lower"]
upper = uncertainty["upper"]
if not (len(lower) == len(upper) == len(y)):
raise ValueError(
"Uncertainty arrays have incorrect lengths"
)
for index, value in enumerate(y):
if missing[index]:
if lower[index] is not None or upper[index] is not None:
raise ValueError(
"Missing observation has uncertainty bounds"
)
continue
lo = lower[index]
hi = upper[index]
if (
isinstance(lo, bool)
or isinstance(hi, bool)
or not isinstance(lo, (int, float))
or not isinstance(hi, (int, float))
or not math.isfinite(lo)
or not math.isfinite(hi)
):
raise ValueError("Invalid uncertainty bound")
if not lo <= value <= hi:
raise ValueError(
"Observed value outside uncertainty bounds"
)
return True
Scope limitation: This example checks numerical
structure, not scientific validity. The bounds-containment rule is
appropriate only for uncertainty definitions that explicitly require
the plotted estimate to lie within the bounds. Some statistical
intervals have different semantics. Production validation should
dispatch to type-specific validators and use a formal schema library
such as Pydantic or JSON Schema.
5. Frontend Accessibility Contract
Frontend implementations must provide accessible figure structure
independently of the rendering library.
Minimum requirements include:
- A programmatically associated title and description.
- A meaningful caption explaining the figure’s scientific context.
- A structured data alternative when needed for equivalent quantitative access.
- Distinguishable series that do not depend exclusively on color.
- Appropriate text and non-text contrast.
- Keyboard access to all essential interactive functions.
- Visible focus indicators for interactive controls.
- Support for resizing and text magnification without loss of essential information.
- No keyboard traps or inaccessible hover-only information.
5.1 Accessible Figure Markup
The following illustrates a possible HTML structure for a scientific
figure. It is an implementation example, not a verified platform
component.
<figure aria-labelledby="figure-title"
aria-describedby="figure-description">
<h3 id="figure-title">
Observed Carbon Removal
</h3>
<div id="figure-description">
Annual measurements increase across three
observations. Uncertainty intervals are displayed.
</div>
<div id="chart-container">
<!-- Accessible chart implementation -->
</div>
<figcaption>
Synthetic demonstration data.
Values are expressed in tonnes CO2 per hectare.
</figcaption>
</figure>
This structure alone is not sufficient for accessibility compliance.
The chart content, interactions, table alternatives, and export
behavior must also be independently tested.
5.2 Alternative Data Representation
When exact values or complex comparisons matter, provide an accessible
table associated with the figure.
| Year | Measured removal (t CO2/ha) | 95% CI lower | 95% CI upper |
|---|---|---|---|
| 2024 | 0.8 | 0.6 | 1.0 |
| 2025 | 1.2 | 0.9 | 1.5 |
| 2026 | 1.5 | 1.1 | 1.9 |
Data note: These values are synthetic acceptance
fixtures, not scientific observations. The confidence intervals
are illustrative.
6. Renderer Adapter Requirements
Sustainable Catalyst’s visualization architecture should support
interchangeable rendering adapters behind a common contract.
Actual support for each engine must be established through
repository and runtime verification.
| Technology | Primary Use | Validation Priority |
|---|---|---|
| Plotly | Interactive scientific and statistical charts | Data fidelity, interaction, keyboard alternatives, static export |
| Vega-Lite | Declarative statistical visualization | Specification validation, transformations, accessible descriptions |
| Matplotlib | Publication-oriented static figures | Units, labels, typography, vector output, descriptive alternatives |
| MapLibre | Interactive geospatial maps | Coordinate correctness, keyboard navigation, layer descriptions |
| CesiumJS | Three-dimensional geospatial visualization | Spatial reference, camera semantics, navigation, equivalent 2D access |
| PyVista | Scientific meshes and 3D simulation results | Mesh integrity, scalar fields, camera effects, static alternatives |
6.1 Adapter Interface
A proposed Python adapter interface is shown below.
from typing import Protocol, Any
class ScientificRenderer(Protocol):
def validate(self, specification: dict) -> None:
...
def render(
self,
specification: dict,
data: dict
) -> Any:
...
def export(
self,
figure: Any,
format: str
) -> bytes:
...
def describe(
self,
specification: dict,
data: dict
) -> dict:
...
The adapter must not independently change source measurements.
If transformations are supported inside a graphics engine,
they must be explicitly represented, validated, and included
in the reproducibility record.
Accessibility descriptions should be derived from verified data
and approved analytical summaries. Automatically generated
narrative must not invent scientific claims.
7. Automated Testing Strategy
Automated tests should cover the full rendering pipeline,
not only individual chart components.
7.1 Unit Tests
Test:
- Schema validation and version compatibility.
- Numeric type validation and non-finite value handling.
- Unit and dimension compatibility.
- Missing-value rules.
- Uncertainty semantics and interval bounds.
- Sorting, filtering, aggregation, and transformations.
- Empty and single-observation datasets.
- Extreme positive and negative magnitudes.
- Logarithmic scale constraints.
- Time zone and coordinate-reference edge cases.
7.2 Golden Fixture Tests
Use small, versioned, synthetic datasets with known expected results.
Fixtures should specify both numerical expectations and required
visual encodings.
A representative pytest example:
import pytest
def test_numeric_series_validation():
series = {
"x": [1, 2, 3],
"y": [10.0, 20.0, 30.0],
"missing": [False, False, False]
}
assert validate_numeric_series(series) is True
def test_reject_non_finite_values():
series = {
"x": [1, 2],
"y": [10.0, float("nan")],
"missing": [False, False]
}
with pytest.raises(ValueError):
validate_numeric_series(series)
def test_reject_mismatched_lengths():
series = {
"x": [1, 2, 3],
"y": [10.0, 20.0],
"missing": [False, False]
}
with pytest.raises(ValueError):
validate_numeric_series(series)
Golden fixtures must not depend on unverified research results.
Real scientific datasets may be added as acceptance fixtures only
after provenance, rights, and expected-value review.
7.3 Accessibility Tests
Automated accessibility checking should include an established
testing engine such as axe-core, combined with browser-based
interaction tests.
Verify:
- Accessible names and descriptions.
- Semantic figure and table relationships.
- Keyboard navigation and focus visibility.
- Meaningful alternatives for chart interactions.
- Text and graphical contrast.
- Resize and magnification behavior.
- Correct handling of dynamic updates.
- Screen-reader usability in selected supported environments.
Important: Automated accessibility tools cannot
establish complete accessibility. Manual inspection and assistive
technology testing remain necessary.
7.4 Visual Regression Tests
Capture representative outputs using a controlled browser environment
with pinned dependencies, fonts, viewport dimensions, and device
scale settings.
Compare screenshots or rasterized exports against reviewed baseline
images to detect layout changes, missing labels, clipped legends,
disappearing markers, and export regressions.
Pixel differences should trigger investigation rather than
automatically establish scientific failure. Numerical and
semantic validation must remain independent of image comparison.
7.5 Property-Based and Metamorphic Tests
Test invariant relationships across generated datasets.
Useful properties include:
- Reordering observations must not alter their numerical values.
- Changing theme colors must not change data or calculations.
- Resizing a chart must not change its underlying data representation.
- Exporting a figure must not alter the authoritative source artifact.
- Identity transformations must preserve all valid observations.
- Known unit conversions must preserve physical quantity.
- Filtering must return only authorized, matching observations.
- Repeated rendering must not mutate the input specification.
7.6 Performance and Resource Tests
Establish performance budgets for small, medium, and large
datasets. Measure rendering time, memory consumption, payload
size, browser responsiveness, and export-worker resource usage.
Large-dataset strategies such as downsampling, aggregation,
tiling, or level-of-detail rendering must declare their
transformations and preserve access to authoritative data.
Do not introduce undocumented sampling that could conceal
outliers, uncertainty, or scientifically important observations.
8. Security and Authorization
Scientific graphics can expose attack surfaces through imported
datasets, user-controlled annotations, embedded HTML, SVG,
external resources, interactive callbacks, and export services.
Minimum security controls:
- Validate and constrain all external inputs.
- Escape untrusted text according to its output context.
- Sanitize SVG or HTML when untrusted markup is permitted.
- Disallow arbitrary JavaScript and unsafe embedded scripts.
- Restrict external asset loading and network access.
- Prevent server-side request forgery in URL-based asset retrieval.
- Apply content security policies where appropriate.
- Enforce dataset access permissions before data retrieval or rendering.
- Validate export permissions independently of frontend controls.
- Protect private dataset identifiers and sensitive metadata from public output.
- Enforce resource limits, execution timeouts, and isolation for rendering workers.
- Scan dependencies and maintain a software bill of materials.
Rendering a figure must not become an alternative route for
retrieving a private dataset or bypassing Workspace and
Research access-control policies.
9. Reproducibility and Provenance
Every publication-grade scientific figure should have a
reproducibility record that identifies:
- Source artifact identifier and immutable version.
- Cryptographic digest of relevant input data.
- Transformation or notebook identifier.
- Calculation code version or commit.
- Figure specification version and digest.
- Rendering engine and dependency versions.
- Relevant environment and export configuration.
- Generated output artifact identifiers and digests.
- Numerical and accessibility validation results.
- Reviewer or approval information, where applicable.
The figure should be reproducible from its declared inputs
without modifying the original dataset.
When an exact pixel match is impossible because of platform-specific
rendering differences, assess numerical equivalence and
preservation of scientifically important visual meaning.
10. CI/CD Acceptance Gates
Introduce automated validation gates into the owning repository’s
existing CI/CD workflow. The following sequence is recommended.
- Validate schemas and fixture integrity.
- Run numerical and unit tests.
- Run transformation and renderer-adapter tests.
- Execute accessibility automation.
- Run browser and interaction tests.
- Generate and validate export artifacts.
- Run security and dependency checks.
- Capture versioned test evidence.
- Require review of scientific or accessibility changes.
- Promote only verified release candidates according to deployment policy.
10.1 Example CI Configuration
This example assumes a Python project with pytest. Paths and
commands must be adapted to the actual repository. The named
checks are illustrative and are not evidence that these tests
already exist.
name: Scientific Figure Validation
on:
pull_request:
push:
branches:
- main
jobs:
figure-validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
- name: Validate scientific contracts
run: |
pytest tests/figures/contracts -q
- name: Test numerical invariants
run: |
pytest tests/figures/numerical -q
- name: Test renderer adapters
run: |
pytest tests/figures/renderers -q
- name: Test export consistency
run: |
pytest tests/figures/exports -q
This workflow covers only the illustrated Python tests.
Browser accessibility, visual regression, dependency scanning,
and deployment acceptance require additional configured jobs.
Action versions and dependency supply-chain controls must be
reviewed against the organization’s current security policy.
10.2 Release Blocking Conditions
A release candidate must be blocked when:
- A numerical regression changes expected scientific values without an approved explanation.
- Required source provenance or artifact identity is missing.
- Unit conversions or uncertainty mappings are invalid.
- Essential information depends exclusively on color.
- A required keyboard interaction is inaccessible.
- Exported figures omit essential scientific information.
- A security test demonstrates unsafe rendering or unauthorized data access.
- Publication permissions or required review gates are bypassed.
- Required acceptance tests fail or have not been executed.
11. Cross-Application Integration Requirements
Sustainable Catalyst should use a shared figure contract across
its scientific and organizational applications rather than
implementing incompatible visualization models in each service.
| Application | Required Integration | Verification Evidence |
|---|---|---|
| Library | Dataset identity, metadata, rights, and provenance resolution | Schema, authorized retrieval tests, source references |
| Workbench | Verified calculations, reusable figure specifications, notebook outputs | Numerical fixtures, reproducibility tests, artifact hashes |
| Lab | Interactive figure exploration and experimental analysis | Browser tests, interface screenshots, adapter tests |
| Site Intelligence | Geospatial layers, coordinate systems, and spatial outputs | Geospatial fixtures, CRS validation, map tests |
| Decision Studio | Model scenarios and comparison figures | Scenario lineage, calculation tests, uncertainty checks |
| Workspace | Project ownership, figure review, and approval state | Authorization tests, review records, workflow acceptance |
| Research | Approved figure references, research context, publication links | Publication references, provenance checks, public/private boundary tests |
| Reporting & Publication Studio | Accessible figure assembly and controlled publication exports | Export inspection, PDF/HTML tests, release receipts |
These integrations must be implemented through documented,
authenticated contracts. A successful frontend preview does
not establish that backend persistence, ownership controls,
or cross-service publication workflows are complete.
12. Source Audit and Product Verification
Before claiming that any Sustainable Catalyst application
supports accessible scientific figures, attach evidence
from the actual codebase and deployed environment.
Required audit record:
- Owning repository and relevant commit SHA.
- Implementation paths for the data adapter and renderer.
- Figure schema and API contract references.
- Rendering engine and dependency versions.
- Current deployment image or release identifier.
- Applicable authentication and authorization mechanisms.
- Unit, integration, accessibility, and export test results.
- Actual browser screenshots or other runtime evidence.
- Known defects, limitations, and unsupported features.
- Reviewers, verification date, and approval status.
12.1 Verification Status Definitions
| Status | Meaning |
|---|---|
| PROPOSED | Contract or implementation design exists but has not been validated in code. |
| IMPLEMENTED | Code exists in an identified repository and revision. |
| TESTED | Specified automated tests have passed with retained evidence. |
| STAGING_VERIFIED | Behavior has been demonstrated in the designated staging environment. |
| PRODUCTION_VERIFIED | Behavior has been verified against the currently deployed production version. |
| REVIEWED | Required scientific, accessibility, and engineering reviews have been completed for the stated scope. |
Verification states should be retained independently where appropriate.
For example, a figure renderer may be production-verified without
having completed independent scientific review.
13. Definition of Done
A scientific figure implementation is ready for acceptance only
when all applicable requirements below are satisfied.
- Versioned figure schema exists and validates successfully.
- Authoritative source data remain unchanged.
- Numerical transformations are explicit and reproducible.
- Uncertainty semantics are validated.
- Essential comparisons remain interpretable without color alone.
- Accessible text and data alternatives are available.
- Essential interactions are keyboard-operable.
- Renderer and export outputs pass their defined tests.
- Known edge cases and resource limits are tested.
- Security and authorization controls are verified.
- Source artifact, code revision, and output provenance are recorded.
- CI test receipts are retained and linked.
- Required review and deployment gates are satisfied.
- Known limitations are documented without overstating capability.
Acceptance principle:
A scientific visualization is not complete merely because it
renders successfully. Its data must be trustworthy, its
scientific meaning preserved, its essential information
accessible, and its output reproducible and auditable.
14. Engineering Deliverables
Teams implementing this contract should produce the following
version-controlled artifacts.
- A figure schema and machine-readable validation rules.
- A renderer-independent specification interface.
- One or more tested renderer adapters.
- Accessibility components and data alternatives.
- Synthetic golden fixtures and expected numerical results.
- Unit, integration, browser, and export tests.
- Security tests and documented resource limits.
- Reproducibility and provenance records.
- CI/CD workflows and retained test receipts.
- Product-specific implementation and deployment verification documentation.
Recommended initial implementation sequence:
establish the shared figure contract, implement one complete
renderer adapter with accessible alternatives, validate
numerical and export behavior, and then expand support
to additional visualization technologies.
This approach reduces duplicated logic and creates a
consistent scientific quality baseline across Sustainable
Catalyst applications.
15. Standards and Engineering References
- W3C. Web Content Accessibility Guidelines (WCAG) 2.2.
https://www.w3.org/TR/WCAG22/
- W3C WAI. Images Tutorial.
https://www.w3.org/WAI/tutorials/images/
- W3C. Accessible Rich Internet Applications (WAI-ARIA).
https://www.w3.org/TR/wai-aria-1.2/
- W3C. Understanding Use of Color.
https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html
- W3C. Understanding Non-text Contrast.
https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html
- Plotly. Python Graphing Library Documentation.
https://plotly.com/python/
- Vega-Lite. Documentation.
https://vega.github.io/vega-lite/
- MapLibre. MapLibre GL JS Documentation.
https://maplibre.org/maplibre-gl-js/docs/
- Cesium. CesiumJS Documentation.
https://cesium.com/learn/cesiumjs/
- PyVista. Documentation.
https://docs.pyvista.org/
- JSON Schema. Specification.
https://json-schema.org/specification
- Deque. axe-core.
https://github.com/dequelabs/axe-core
Refer to version-specific documentation when implementing or
verifying individual frameworks. These references establish
general engineering guidance, not proof of current
Sustainable Catalyst functionality.
