Simulate colorblindness in Python charts
Project description
realcolor: simulate colorblindness in Python charts
realcolor is a lightweight Python package designed to show how colorblind people see your graphs. It simulates all types of colorblindness (deuteranopia, protanopia, tritanopia) by showing you your graphic as seen by a colorblind person. It works with matplotlib and everything built on top of it (seaborn, plotnine, etc).
[!NOTE] Colorblindness affects up to 1 in 12 males (8%) and 1 in 200 females (0.5%)[^1]
Installation
pip install realcolor
Quick start
- Matplotlib
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 2, 5], label="Group A", lw=4)
ax.plot([1, 2, 3], [2, 5, 3], label="Group B", lw=4)
ax.legend()
from realcolor import simulate_colorblindness
simulate_colorblindness(fig)
- Plotnine
from plotnine import ggplot, geom_point, aes
from plotnine.data import anscombe_quartet
from realcolor import simulate_colorblindness
ggp = ggplot(anscombe_quartet, aes(x="x", y="y", color="dataset")) + geom_point(size=10)
simulate_colorblindness(ggp)
[!TIP] Looking for support of other data visualization libraries? Open an issue.
Other features
- Simulate just one kind of colorblindness (one of
"deuteranopia","protanopia","tritanopia","desaturated"):
simulate_colorblindness(fig, kind="protanopia")
- Control the severity of the simulation (between 0 to 100, default to 100):
simulate_colorblindness(fig, kind="protanopia", severity=50)
- Score how colorblind-friendly a set of colors is (0 = indistinguishable, 100 = perfectly distinguishable):
from realcolor import colorblind_score
score = colorblind_score(["red", "green", "blue"])
score.overall
#> 52.1
score.deuteranopia
#> {"score": 66.7, "min_deltaE": 16.7, "worst_pair": ("#ff0000", "#008000")}
[^1]: Deane B. Judd, "Facts of Color-Blindness*," J. Opt. Soc. Am. 33, 294-307 (1943)
Project details
Release history Release notifications | RSS feed
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 realcolor-0.2.0.tar.gz.
File metadata
- Download URL: realcolor-0.2.0.tar.gz
- Upload date:
- Size: 419.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddfb8e29a79361bf86d8a84b4bf613aa43f897050776242e3aa6875741818aa3
|
|
| MD5 |
73782cd43701194eb80f56839bef5871
|
|
| BLAKE2b-256 |
5a32810b6584e938785e5e08aa0e4486cf78773d174d5b9e640a0eaddf72f32a
|
Provenance
The following attestation bundles were made for realcolor-0.2.0.tar.gz:
Publisher:
pypi.yaml on y-sunflower/realcolor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
realcolor-0.2.0.tar.gz -
Subject digest:
ddfb8e29a79361bf86d8a84b4bf613aa43f897050776242e3aa6875741818aa3 - Sigstore transparency entry: 928514087
- Sigstore integration time:
-
Permalink:
y-sunflower/realcolor@f8a0fd336a5b4cd59a17e61ce4cdcd5f133dfc52 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/y-sunflower
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@f8a0fd336a5b4cd59a17e61ce4cdcd5f133dfc52 -
Trigger Event:
push
-
Statement type:
File details
Details for the file realcolor-0.2.0-py3-none-any.whl.
File metadata
- Download URL: realcolor-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16b63c44c86a2d2773fb2dd6b31c924bed2bb8aad1f293ea6551dbe5e45b44c8
|
|
| MD5 |
7e67f7d0e9c6c0a640ff5c9b7a52f8f4
|
|
| BLAKE2b-256 |
34a0f5b2ab95a97ebd4c7170cde0f834fa06920d5ae72a2972f834ffec66d421
|
Provenance
The following attestation bundles were made for realcolor-0.2.0-py3-none-any.whl:
Publisher:
pypi.yaml on y-sunflower/realcolor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
realcolor-0.2.0-py3-none-any.whl -
Subject digest:
16b63c44c86a2d2773fb2dd6b31c924bed2bb8aad1f293ea6551dbe5e45b44c8 - Sigstore transparency entry: 928514099
- Sigstore integration time:
-
Permalink:
y-sunflower/realcolor@f8a0fd336a5b4cd59a17e61ce4cdcd5f133dfc52 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/y-sunflower
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@f8a0fd336a5b4cd59a17e61ce4cdcd5f133dfc52 -
Trigger Event:
push
-
Statement type: