Economist-style chart theme for matplotlib/seaborn
Project description
graphs
Economist-style chart theme for matplotlib and seaborn — global theme, title-stack finaliser with renderer-measured wrapping, on-grid axis labels, direct line labels, CI bands, and a catalogue of chart helpers (bars, dumbbells, thermometers, bump charts, lollipops). IBM Plex Sans typography and a curated palette.
Install
pip install djrhails-graphs
PyPI distribution is djrhails-graphs because the bare name graphs is taken.
The import package is graphs.
Quick start
import matplotlib.pyplot as plt
import numpy as np
from graphs import finalize, label_lines, save_chart, set_theme, subplots
set_theme()
x = np.arange(12)
fig, ax = subplots("wide")
ax.plot(x, 40 + 2.1 * x, label="Series A")
ax.plot(x, 58 - 1.3 * x, label="Series B")
label_lines(ax)
finalize(
ax,
title="State the finding, not the topic",
descriptor="Country, metric, unit",
source="Source: Organisation",
)
save_chart(__file__)
finalize() does the heavy lifting: auto-sized margins, title stack with the
delta marker (titles auto-wrap to the figure width), numeric y labels seated
on gridlines that extend under them, source line, right-hand y-axis.
SKILL.md is the full manual — design principles, headline
conventions, the complete API table, and a when-to-use index of 39 worked
examples in examples/.
Palette
from graphs import PALETTE, colors, C_RED, C_RED_BRAND, C_SPINE, C_GRID, C_LABEL
Nine named colours in PALETTE (red-led default cycle); structural greys for
spines/grid/labels/source; cycle_for(chart_type) for per-chart-type orders.
Typography
IBM Plex Sans (headlines) and IBM Plex Sans Condensed (everything else) are
loaded automatically. If already registered in matplotlib's font manager, no
download occurs. Otherwise TTFs are fetched from github.com/IBM/plex on
first use and cached inside the installed package.
Fallback chain: IBM Plex Sans Condensed → IBM Plex Sans → Verdana → Arial → DejaVu Sans.
Development
Hot reload:
uv run graphs-watch
Watches graphs/ and examples/ for .py changes and re-renders the affected
examples + comparisons. Tests: uv run --with pytest pytest -q. Reference
images for the replica examples: uv run examples/fetch_refs.py, then
uv run examples/build_comparisons.py.
License
MIT. See LICENSE.
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 djrhails_graphs-0.5.0.tar.gz.
File metadata
- Download URL: djrhails_graphs-0.5.0.tar.gz
- Upload date:
- Size: 120.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb899b61898e1feae6d97d6f42b0ce351f6eac8a37d7dbe0253d5921af6c8691
|
|
| MD5 |
fb2f2923bfdb0406ba299814d5e494cf
|
|
| BLAKE2b-256 |
dd406cce1691346e3950fae094f90705fdbf48a20cb542bdcece85ecb85cbb9c
|
Provenance
The following attestation bundles were made for djrhails_graphs-0.5.0.tar.gz:
Publisher:
release.yml on DJRHails/graphs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djrhails_graphs-0.5.0.tar.gz -
Subject digest:
bb899b61898e1feae6d97d6f42b0ce351f6eac8a37d7dbe0253d5921af6c8691 - Sigstore transparency entry: 1795097179
- Sigstore integration time:
-
Permalink:
DJRHails/graphs@c6e60ad1962d53ddea8766be4a9f095dfd451586 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/DJRHails
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c6e60ad1962d53ddea8766be4a9f095dfd451586 -
Trigger Event:
push
-
Statement type:
File details
Details for the file djrhails_graphs-0.5.0-py3-none-any.whl.
File metadata
- Download URL: djrhails_graphs-0.5.0-py3-none-any.whl
- Upload date:
- Size: 153.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e3bb86e4449136d76e738d1d30edcaaadee65911fa7394f806d5a01ac020ecd
|
|
| MD5 |
5a19039ecb6535a217156a0bd0007fad
|
|
| BLAKE2b-256 |
b655a1f0ff042f842e1464d5a9d863f0f52fd8ac3ee121a7458ecebd7e40fabc
|
Provenance
The following attestation bundles were made for djrhails_graphs-0.5.0-py3-none-any.whl:
Publisher:
release.yml on DJRHails/graphs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djrhails_graphs-0.5.0-py3-none-any.whl -
Subject digest:
1e3bb86e4449136d76e738d1d30edcaaadee65911fa7394f806d5a01ac020ecd - Sigstore transparency entry: 1795097398
- Sigstore integration time:
-
Permalink:
DJRHails/graphs@c6e60ad1962d53ddea8766be4a9f095dfd451586 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/DJRHails
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c6e60ad1962d53ddea8766be4a9f095dfd451586 -
Trigger Event:
push
-
Statement type: