gp_treemap
Python wrapper around gp-treemap:
turn a pandas DataFrame into a self-contained, interactive treemap HTML
page. Mirrors the spirit of plotly.express.treemap for the
path/values/color arguments, but emits the HTML directly — no
Plotly Figure intermediate.
Install
pip install gp_treemap
The JS bundle and loader ship as package data, so the rendered HTML is fully offline: no CDN, no network fetch.
Usage
import pandas as pd
from gp_treemap import treemap
df = pd.DataFrame({
"continent": ["EU", "EU", "AS", "AS"],
"country": ["FR", "DE", "CN", "JP"],
"fuel": ["nuclear", "coal", "coal", "nuclear"],
"twh": [380, 280, 5400, 70],
})
fig = treemap(df, path=["continent", "country", "fuel"], values="twh",
color="fuel", title="2023 generation by fuel")
fig.write_html("out.html") # standalone file
fig.show() # open in browser
fig # in Jupyter, renders inline (iframe srcdoc)
Arguments
path: column names describing the hierarchy, outermost first.values: numeric column whose per-group sum drives cell size. Defaults to row-count.color: column name. Numeric → continuous palette; non-numeric → categorical hash. Pass"[Level 1]"(or leavecolor=None) to colour by the topmost visible ancestor — recomputed every time you zoom.theme,palette: gpdu themes / palettes ("tokyo-night","nord","viridis","turbo", …).
Development
This package wraps the JS bundle built from the root of the repo. After
running node tools/build.js at the repo root, refresh the bundled
artifacts:
bash python/scripts/refresh_bundle.sh
Then run the tests:
cd python
python -m venv .venv && .venv/bin/pip install -e . pytest pandas numpy
.venv/bin/pytest
Metadata
Release files for gp_treemap 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gp_treemap-0.6.2.tar.gz | 54.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gp_treemap-0.6.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 109.1 kB
Release files / gp_treemap-0.6.2.tar.gz
| Download URL | gp_treemap-0.6.2.tar.gz |
|---|---|
| Size | 54.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
afff263a821d0817e3ee6501a4590d226a2682c9999bf9e50f54dc8ab4e10290
|
|
BLAKE2b-256 checksum How to use checksums |
b62f3a9abd55c5a3bb8e95e35cdedc21419c1e61c3b5eee55ea3ed9b2a494437
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / gp_treemap-0.6.2-py3-none-any.whl
| Download URL | gp_treemap-0.6.2-py3-none-any.whl |
|---|---|
| Size | 55.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0ba1e12020c78b041c0712a3e2dfebee639b7f60a33c2821f3b7f2c69b56f1b
|
|
BLAKE2b-256 checksum How to use checksums |
dbc5ec0139b725fa7cc5f6ffc145c099d01c8f383cc768f5003d0a82aae7ce61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|