╔════════════════════════════════════════════════════════════════════════════════════════════╗
║ ║
║ ██████╗ ██████╗ ████████╗██╗ ██████╗ ██████╗ ██╗ ██╗██╗███████╗ ║
║ ██╔═══██╗██╔══██╗╚══██╔══╝██║██╔════╝██╔═══██╗██║ ██║██║╚══███╔╝ ║
║ ██║ ██║██████╔╝ ██║ ██║██║ ██║ ██║██║ ██║██║ ███╔╝ ║
║ ██║ ██║██╔═══╝ ██║ ██║██║ ██║▄▄ ██║██║ ██║██║ ███╔╝ ║
║ ╚██████╔╝██║ ██║ ██║╚██████╗╚██████╔╝╚██████╔╝██║███████╗ ║
║ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══▀▀═╝ ╚═════╝ ╚═╝╚══════╝ ║
║ ║
║ ██████╗██╗ ██╗██████╗ ║
║ ██╔════╝██║ ██║██╔══██╗ ║
║ ██║ ██║ ██║██║ ██║ ║
║ ██║ ╚██╗ ██╔╝██║ ██║ ║
║ ╚██████╗ ╚████╔╝ ██████╔╝ ║
║ ╚═════╝ ╚═══╝ ╚═════╝ ║
║ ║
║ measure a palette before you trust it ║
║ ║
╚════════════════════════════════════════════════════════════════════════════════════════════╝
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, fixes it if it fails, and also checks WCAG contrast — with zero dependencies, dropping straight into a matplotlib / plotly / seaborn workflow.
It simulates protanopia, deuteranopia and tritanopia (Machado 2009, or Brettel 1997) and scores perceptual difference with CIEDE2000, flagging pairs that are 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
Check 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, or 0-1 / 0-255 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"])
check_palette(colors, distinct=13, collapse=10, severity=1.0, model="machado") — severity (0–1) checks milder anomalous trichromacy; model is "machado" or "brettel".
Fix a failing palette
fixed = cvd.fix_palette(["#d7191c", "#1a9641"])
fixed["colors"] # ['#c80011', '#2da24c'] — now colorblind-safe
fixed["drift"] # [4.0, 4.1] — how far each color moved (CIEDE2000)
fixed["pass"] # True
Check contrast (WCAG)
cvd.check_contrast("#767676", "#ffffff")
# {'ratio': 4.54, 'AA': True, 'AAA': False, 'ui': True, 'pass': True}
cvd.contrast_ratio("#000000", "#ffffff") # 21.0
Simulate
cvd.simulate("#d7191c", "deutan") # '#8a7b0c' (Machado, full)
cvd.simulate("#d7191c", "deutan", 0.5) # milder
cvd.simulate("#d7191c", "deutan", 1.0, "brettel")
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 — an approximation of a diverse population, not any single person's vision — and results depend on an uncalibrated screen. Severity below 1 is a disclosed approximation of anomalous trichromacy. It is not a legal accessibility audit and does not certify ADA / Section 508 / WCAG / EU Accessibility Act compliance.
License
MIT. Methods: Machado, Oliveira & Fernandes (2009); Brettel, Viénot & Mollon (1997); CIEDE2000; WCAG 2.x. Part of OpticQuiz.
╔════════════════════════════════════════════════════════════╗
║ ║
║ ███████╗ ██╗ ██╗███████╗██╗ ██╗███████╗ ║
║ ██╔════╝ ██║ ██╔╝██╔════╝╚██╗ ██╔╝██╔════╝ ║
║ █████╗ █████╗█████╔╝ █████╗ ╚████╔╝ ███████╗ ║
║ ██╔══╝ ╚════╝██╔═██╗ ██╔══╝ ╚██╔╝ ╚════██║ ║
║ ██║ ██║ ██╗███████╗ ██║ ███████║ ║
║ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝ ║
║ ║
║ · C R E A T I V E · ║
║ ║
║ ──────────────────────────────────────── ║
║ ║
║ Vincent Gonzalez ║
║ f-keys.com ║
║ ORCID 0009-0005-3640-014X ║
║ ║
╚════════════════════════════════════════════════════════════╝
Part of F-Keys — independent hardware, software and internet products. See the working log and live status.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opticquiz_cvd-1.1.2.tar.gz.
File metadata
- Download URL: opticquiz_cvd-1.1.2.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22f5f3c9f38ba97889d65af8636a171e6abb632f9cf9dd6b92a6f9077f7c6de4
|
|
| MD5 |
8227a6ae8450b03b0c0128ec9dc629f0
|
|
| BLAKE2b-256 |
a630ad4e514901c49bd0598808b71d8450e118933001761786862aa7afede374
|
File details
Details for the file opticquiz_cvd-1.1.2-py3-none-any.whl.
File metadata
- Download URL: opticquiz_cvd-1.1.2-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b665df8e827f19f55d925986c917c9b33bde8930b840110ddb6821e35476b69f
|
|
| MD5 |
328c8267ab99a942aa20856b3cb7f2f0
|
|
| BLAKE2b-256 |
65b812332e28a4820a35ae5c48cd0cf5bd0af7d36e1ce5badb9096ca21dbf504
|