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, 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 labels
  • faceted_chart.py — three-panel faceted layout with panel labels
  • bar_chart.py — horizontal bar with max-value highlight
  • dumbbell_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


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.1.0.tar.gz (14.7 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.1.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

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

Hashes for djrhails_graphs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ef4566ee7c8dc3935393e7196e97f712ed2210f97e81efe70d22e7d687c2600
MD5 f9176486120f5c50a1ed27219d16f834
BLAKE2b-256 bf3cd054e8aac085b7db26b36040e080e44cd9aaa6d4196ed1b5ee735120e884

See more details on using hashes here.

Provenance

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

Hashes for djrhails_graphs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 792fd5f5093678c745b4ea8a1316dc23f34799db40bd8c8a63a88c4e0fe8fb35
MD5 abeb9aa0ecd369c34349853549aeb468
BLAKE2b-256 edd2fd5fcd78c8b705fe7bf97bc9c5c38a19494dca62e632bb9da1573b867551

See more details on using hashes here.

Provenance

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