Economist-style chart theme for matplotlib/seaborn
Project description
graphs
Economist-style chart theme for matplotlib and seaborn — global theme, title-stack finaliser, direct line labels, CI bands, horizontal bars, and dumbbell charts. Uses IBM Plex Sans typography and a curated 8-colour palette.
Version: 0.1.0
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
from graphs import ci_fill, finalize, label_lines, set_theme
set_theme()
fig, ax = plt.subplots()
fig.subplots_adjust(top=0.68, bottom=0.14, left=0.06, right=0.88)
ax.plot(x, y, label="Series A")
label_lines(ax)
finalize(
ax,
title="Bold chart title",
descriptor="Country, metric, unit",
source="Source: Organisation",
)
See examples/ for runnable scripts:
line_chart.py— multi-series line with CI bands + direct labelsfaceted_chart.py— three-panel faceted layout with panel labelsbar_chart.py— horizontal bar with max-value highlightdumbbell_chart.py— before/after comparison with legend
Public API
| Function | Purpose |
|---|---|
set_theme() |
Apply global rcParams (figure, axes, ticks, fonts, palette) |
finalize(ax, title, descriptor, source, *, y_axis_right, title_x, y_start, autoscale_y) |
Title stack, red rule, source line, y-axis tidy-up |
label_lines(ax, ...) |
Direct end-of-line labels with collision avoidance |
smart_legend(ax, ...) |
Pick the emptiest corner of the axes |
ci_fill(ax, x, y_lo, y_hi, *, color) |
Confidence-interval band |
bar_h(ax, categories, values, *, highlight_max) |
Horizontal bar chart |
dumbbell(ax, categories, start, end, ...) |
Dot-and-line before/after chart |
panel_label(ax, label) |
Bold panel sub-heading for facets |
Palette
from graphs import colors, C_BG, C_RED, C_SPINE, C_GRID, C_LABEL, C_TEXT, C_CI
Sequence colors (red primary, blue, teal, green, yellow, mauve, slate, coral).
Typography
IBM Plex Sans is 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 → Verdana → Arial → DejaVu Sans.
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.1.0.tar.gz.
File metadata
- Download URL: djrhails_graphs-0.1.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ef4566ee7c8dc3935393e7196e97f712ed2210f97e81efe70d22e7d687c2600
|
|
| MD5 |
f9176486120f5c50a1ed27219d16f834
|
|
| BLAKE2b-256 |
bf3cd054e8aac085b7db26b36040e080e44cd9aaa6d4196ed1b5ee735120e884
|
Provenance
The following attestation bundles were made for djrhails_graphs-0.1.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.1.0.tar.gz -
Subject digest:
0ef4566ee7c8dc3935393e7196e97f712ed2210f97e81efe70d22e7d687c2600 - Sigstore transparency entry: 1601302892
- Sigstore integration time:
-
Permalink:
DJRHails/graphs@9d648f9d8929f71065aab011213355a2a5a225ac -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DJRHails
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9d648f9d8929f71065aab011213355a2a5a225ac -
Trigger Event:
push
-
Statement type:
File details
Details for the file djrhails_graphs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: djrhails_graphs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.1 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 |
792fd5f5093678c745b4ea8a1316dc23f34799db40bd8c8a63a88c4e0fe8fb35
|
|
| MD5 |
abeb9aa0ecd369c34349853549aeb468
|
|
| BLAKE2b-256 |
edd2fd5fcd78c8b705fe7bf97bc9c5c38a19494dca62e632bb9da1573b867551
|
Provenance
The following attestation bundles were made for djrhails_graphs-0.1.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.1.0-py3-none-any.whl -
Subject digest:
792fd5f5093678c745b4ea8a1316dc23f34799db40bd8c8a63a88c4e0fe8fb35 - Sigstore transparency entry: 1601302987
- Sigstore integration time:
-
Permalink:
DJRHails/graphs@9d648f9d8929f71065aab011213355a2a5a225ac -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DJRHails
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9d648f9d8929f71065aab011213355a2a5a225ac -
Trigger Event:
push
-
Statement type: