Skip to main content

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

set_theme()

x = np.arange(12)
fig, ax = plt.subplots(figsize=(7, 4.4))
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


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.4.0.tar.gz (119.3 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.4.0-py3-none-any.whl (152.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: djrhails_graphs-0.4.0.tar.gz
  • Upload date:
  • Size: 119.3 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.4.0.tar.gz
Algorithm Hash digest
SHA256 69047bafbc5e5c292e1aa7047e72152a480e103926276b1172851d40c353e621
MD5 4609a51507015393d69f67b2a7277e34
BLAKE2b-256 d7441a1d5c0e8da80763db747b3d6575afcd31df02f15a88a11e09defe54f8b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for djrhails_graphs-0.4.0.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.4.0-py3-none-any.whl.

File metadata

  • Download URL: djrhails_graphs-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 152.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for djrhails_graphs-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 456d4aa6ee6ab2a96d0ff0190c441d9e542a04f34514ecf25e732116a3c0c0ab
MD5 96c6cf6d62e8731a5f6ebbbd0f8c9c2b
BLAKE2b-256 083bee3bd5c4e55aa9b2e00105708e11af4668db5862945ac93f1e1e2cbbd2ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for djrhails_graphs-0.4.0-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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page