ColorEx is a lightweight Python library for rendering tabular numeric data into deterministic 2D heatmaps.
pip install colorexfrom colorex import Heatmap
hm = Heatmap(
[[1, 5, 2], [3, 9, 4], [6, 7, 8]],
title="Quickstart",
subtitle="Linear normalization",
)
hm.to_html("output.html")import pandas as pd
from colorex import Heatmap
# Requires: pip install "colorex[pandas]"
df = pd.DataFrame(
[[10, 20, 30], [40, None, 60], [70, 80, 90]],
columns=["A", "B", "C"],
index=["r1", "r2", "r3"],
)
hm = Heatmap(df, normalize="quantile", title="DataFrame Heatmap")
hm.to_html("df_heatmap.html")from colorex import Heatmap
hm = Heatmap(
"input.csv",
normalize="log",
show_values=True,
title="CSV Heatmap",
)
hm.to_html("csv_heatmap.html")
hm.to_image("csv_heatmap.png")colorex render input.csv --out output.html --theme blue-red --normalize linear --show-valuesPNG output:
colorex render input.csv --out output.png --theme mono-dark --normalize quantileBuilt-in themes:
blue-redgreen-yellowmono-darkmono-light
Use a built-in theme:
from colorex import Heatmap
hm = Heatmap([[1, 2], [3, 4]], theme="green-yellow")Use a custom theme:
from colorex import Heatmap, Theme
custom = Theme(primary="#1D4ED8", secondary="#F59E0B", neutral="#E5E7EB")
hm = Heatmap([[1, None], [3, 4]], theme=custom)Heatmap(
data,
theme=None,
normalize="linear",
show_values=False,
title=None,
subtitle=None,
)Accepted data:
pandas.DataFrame- 2D list of numeric values (
Noneallowed) - CSV file path
Behavior:
- Missing values default to
Noneand render using themeneutral. - Optional strict mode:
Heatmap(..., strict_missing=True)raises on missing values. - Normalization modes:
linear,log,quantile.
Methods:
to_html(path, legend=True) -> strto_image(path) -> None(requires Pillow)show() -> None(opens image with system viewer; requires Pillow)
- No native Tkinter interactive window renderer in the current
colorexpackage. - HTML output is renderer-defined; there is no external template/plugin system yet.
show()is an image preview path (via Pillow), not an interactive heatmap UI.- PNG export depends on optional Pillow installation.
- DataFrame support requires optional pandas installation (
colorex[pandas]). - The current renderer focuses on cell color/value visualization and does not yet expose advanced chart features (for example: clustering, annotations, or dashboard embedding components).
Install dev dependencies:
pip install -e ".[dev,pandas,image]"
pytestRunnable examples are in examples/:
python examples/example1/run.py(50x50 CSV dataset)python examples/example2/run.py(in-memory data with missing values)python examples/example3/run.py(CLI-driven rendering)
Apache License 2.0. See LICENSE.md.
