realcolor is a lightweight Python package designed to show how colorblind people see your graphs. It simulates all types of colorblindness (deuteranopia, protanopia, tritanopia).
It works with the following library: matplotlib, seaborn, plotnine and plotly.
Note
Colorblindness affects up to 1 in 12 males (8%) and 1 in 200 females (0.5%)1
pip install realcolor- Matplotlib
import matplotlib.pyplot as plt
from realcolor import simulate_colorblindness
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()
simulate_colorblindness(fig)- Plotnine
from plotnine import ggplot, geom_point, aes
from plotnine.data import anscombe_quartet
from realcolor import simulate_colorblindness
gg = ggplot(anscombe_quartet, aes(x="x", y="y", color="dataset")) + geom_point(size=10)
simulate_colorblindness(gg)- Plotly
import plotly.express as px
from realcolor import simulate_colorblindness
fig = px.scatter(
x=[1, 2, 3, 4],
y=[4, 2, 5, 3],
color=["Group A", "Group A", "Group B", "Group B"],
)
simulate_colorblindness(fig)- 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")}-
Fork the repository to your own GitHub account.
-
Clone your forked repository to your local machine (ensure you have Git installed):
git clone https://github.com/YOUR_NAME/realcolor.git
cd realcolor- Create a new branch:
git checkout -b my-feature- Set up your Python environment (ensure you have uv installed):
uv sync --all-extras --dev
uv run pre-commit install
uv pip install -e .- Test that everything works correctly by running:
uv run pytestFootnotes
-
Deane B. Judd, "Facts of Color-Blindness*," J. Opt. Soc. Am. 33, 294-307 (1943) ↩




