Skip to main content

Color accessibility engine: colorblind-safety (protan/deutan/tritan, Machado 2009 + CIEDE2000), palette fixing, and WCAG contrast. Zero dependencies; drops into any matplotlib/plotly workflow.

Project description

opticquiz-cvd (Python)

Is your chart colorblind-safe? Red-green color-vision deficiency affects ~1 in 12 men — and the classic failure is a plot where the red series and the green series look identical to those readers. This checks any palette for that, with zero dependencies, and drops straight into a matplotlib / plotly / seaborn workflow.

It simulates protanopia, deuteranopia and tritanopia (Machado, Oliveira & Fernandes, 2009) and scores perceptual difference with CIEDE2000, flagging pairs that are clearly distinct to normal vision but collapse under a color-vision-deficiency simulation.

Method (citable): https://doi.org/10.5281/zenodo.21310578

Install

pip install opticquiz-cvd

Use it on a chart palette

import opticquiz_cvd as cvd

report = cvd.check_palette(["#d7191c", "#1a9641", "#2166ac"])
report["pass"]                         # False
report["types"]["deutan"]["conflicts"]
# [{'a': '#d7191c', 'b': '#1a9641', 'normal': 70.6, 'sim': 8.1, 'severity': 'risk'}]

Works directly with matplotlib colors (hex, names, or 0-1 RGB tuples):

import matplotlib.pyplot as plt, opticquiz_cvd as cvd
cycle = plt.rcParams["axes.prop_cycle"].by_key()["color"]
print("colorblind-safe:", cvd.check_palette(cycle)["pass"])

cvd.simulate((0.84, 0.10, 0.11), "deutan")   # '#8a7b0c'  (how a deuteranope sees it)
cvd.delta_e("#d7191c", "#1a9641")            # 70.6

Command line:

python -m opticquiz_cvd "#d7191c" "#1a9641" "#2166ac"
# FAIL - color conflicts found (3 colors)
#   deutan: #d7191c/#1a9641 dE8.1(risk)

Honest scope

Simulates a model of color-vision deficiency — an approximation of a diverse population, not any single person's vision — and results depend on an uncalibrated screen. It reliably catches classic red-green and blue-yellow conflicts. It is not a legal accessibility audit and does not certify ADA / Section 508 / WCAG / EU Accessibility Act compliance.

License

MIT. Method: Machado, Oliveira & Fernandes (2009) + CIEDE2000. Part of OpticQuiz.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opticquiz_cvd-1.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opticquiz_cvd-1.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file opticquiz_cvd-1.1.0.tar.gz.

File metadata

  • Download URL: opticquiz_cvd-1.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for opticquiz_cvd-1.1.0.tar.gz
Algorithm Hash digest
SHA256 acacb2f49d50c59f5a05bb6751061fd28b8588eb9c4a4f4ce615edff6e80b706
MD5 0c5d79b1ea987ce7287089ee36046082
BLAKE2b-256 86528bcb2bd19acda4bc86df382d18e22942d9a3a6e2893e383fd9b37d28a115

See more details on using hashes here.

File details

Details for the file opticquiz_cvd-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: opticquiz_cvd-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for opticquiz_cvd-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a109501adee5b46325b8992824da9ea77fbd968f420fe4a987a90673db827d7
MD5 df038ebf25fbfbad1d014d83f2a7060f
BLAKE2b-256 0b595f37f149ada6f1d55ba06b38d72271a1b02803adfa6355dc1e4918e14c2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page