Skip to main content

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 during chart iteration:

uv run graphs-watch

Watches graphs/ and examples/ for .py changes and re-renders the affected examples + the comparison strip in parallel. The watcher routes by path:

  • graphs/**/*.py or examples/_data.py → regen all examples + comparisons
  • examples/build_comparisons.py → comparisons only
  • examples/<name>.py → that one example + comparisons

Comparison harness

examples/build_comparisons.py composes side-by-side images for visual review:

  • url-kind entries download a Medium-hosted PNG and stack it above our replica (used for the "Mistakes, we've drawn a few" redesigns).
  • local_ref-kind entries use a local reference image (e.g. the styleguide page for the thermometer chart).

Generated comparisons land in examples/comparisons/<name>.png (gitignored — the reference images aren't ours to redistribute).

examples/fetch_refs.py populates examples/comparisons/_originals/ for the daily-chart replicas: it downloads the Economist "2019 daily charts" grid and cuts it into per-chart reference cells (rows are located via the red Economist tag that tops every chart — blank-gap heuristics misfire on detached titles/footnotes).

CSVs fetched at runtime by example scripts are cached under examples/.data/ via examples/_data.py::load_csv_text(url).

License

MIT. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djrhails_graphs-0.10.1.tar.gz (162.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

djrhails_graphs-0.10.1-py3-none-any.whl (200.7 kB view details)

Uploaded Python 3

File details

Details for the file djrhails_graphs-0.10.1.tar.gz.

File metadata

  • Download URL: djrhails_graphs-0.10.1.tar.gz
  • Upload date:
  • Size: 162.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for djrhails_graphs-0.10.1.tar.gz
Algorithm Hash digest
SHA256 b0842c7c1d1c5cc613c941462b62698a96fc7e351fc8e4d81f659a040121eba7
MD5 d3a1b856dfc01e447b8465ffaf12a618
BLAKE2b-256 c4e235ab49dd07e22fe4c9a9810060451fffcc95a6fbb684400b9d2ff0562a73

See more details on using hashes here.

Provenance

The following attestation bundles were made for djrhails_graphs-0.10.1.tar.gz:

Publisher: release.yml on DJRHails/graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file djrhails_graphs-0.10.1-py3-none-any.whl.

File metadata

File hashes

Hashes for djrhails_graphs-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8f418e96e2670ea5c3184da52acd3fe127d80b48dc0bdd23524edb9883b4dcc
MD5 27c8ce8c45bfc2e98c8ca3edcf3c950f
BLAKE2b-256 9049fd7363bf59a8062a36687b8d08bfad8f3b05f1123f3e95d1441a2353386f

See more details on using hashes here.

Provenance

The following attestation bundles were made for djrhails_graphs-0.10.1-py3-none-any.whl:

Publisher: release.yml on DJRHails/graphs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.14.1

2 files

0.14.0

2 files

0.13.0

2 files

0.12.1

2 files

0.12.0

2 files

0.11.3

2 files

0.11.0

2 files

This release

0.10.1 This release

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.5

2 files

0.6.4

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.5

2 files

0.5.4

2 files

0.5.2

2 files

0.5.0

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page