Skip to main content

SpiffyPlots

Tests Documentation Status PyPI version GitHub last commit MIT license

A collection of matplotlib style sheets and plotting tools for publication-ready figures.

Requires Python 3.10 or newer and Matplotlib 3.8 or newer.

Simple style example:

style example

Installation

Install the latest release:

pip install spiffyplots

or install the latest commit directly from GitHub:

pip install git+https://github.com/JRBCH/spiffyplots.git

For local development, install uv and run:

uv sync
uv run ruff check .
uv run pytest

Using the style sheets

The style sheets ship inside the package and register themselves with matplotlib when spiffyplots is imported:

import spiffyplots  # registers the styles and colormaps
import matplotlib.pyplot as plt

plt.style.use("spiffy")  # base style
plt.style.use(["spiffy", "tol-muted"])  # base style plus a color scheme

Import spiffyplots before calling plt.style.use. The base style names a colormap that this package registers, and a style sheet naming an unregistered colormap applies silently and then fails at draw time.

Available styles:

base spiffy
color tol-bright, tol-high-contrast, tol-light, tol-medium-contrast, tol-muted, tol-vibrant, okabe-ito
modifiers latex, minor-ticks, right-axis, top-axis

The base spiffy style keeps vector text editable. PDF and PostScript embeds TrueType fonts, and SVG retains <text> elements instead of converting glyphs to paths.

If for some reason you want to restore Matplotlib's default outlined SVG behavior, set plt.rcParams["svg.fonttype"] = "path".

Colors and colormaps

Style sheets only set the default cycle. For the colors themselves, use spiffyplots.colors for discrete colors and spiffyplots.cmap for colormaps.

import spiffyplots as spiffy

scheme = spiffy.colors.tol_vibrant
color_exc = scheme.red  # '#CC3311'
color_inh = scheme.blue  # '#0077BB'

spiffy.colors.from_cmap(spiffy.cmap.sequential, 6)  # 6 equally spaced colors
spiffy.colors.shades(color_exc, 5)  # 5 shades of one base color

Schemes: tol_bright, tol_high_contrast, tol_vibrant, tol_muted, tol_medium_contrast, tol_light, tol_pale, tol_dark and okabe_ito. Each is a tuple you can index, slice and iterate, whose colors are also reachable by name. Each runs in its author's recommended order, then black, then grey.

cmap = spiffy.cmap.sequential  # Paul Tol's iridescent
cmap = spiffy.cmap.diverging  # Paul Tol's nightfall
cmap = spiffy.cmap.iridescent_r  # any of Tol's, by short name
cmap = spiffy.cmap.viridis  # falls through to matplotlib
cmap = spiffy.cmap.batlow  # falls through to cmcrameri
cmap = spiffy.cmap.kbc  # falls through to colorcet

cmap = spiffy.cmap.from_base(color_exc)  # white -> color -> darker
cmap = spiffy.cmap.from_colors(spiffy.colors.tol_muted)
cmap = spiffy.cmap.discrete_rainbow(8)

Perceptually uniform colormaps

cmcrameri and colorcet do that very well, and spiffy.cmap reaches their colormaps too once either is installed. To install them together with spiffyplots:

pip install "spiffyplots[colormaps]"
import spiffyplots as spiffy

cmap = spiffy.cmap.batlow  # cmcrameri, registered as `cmc.batlow`
cmap = spiffy.cmap.kbc  # colorcet, registered as `cet_kbc`
  • Matplotlib style sheets

  • Colors

    • Easy access to colors and colormaps
    • Ramps and shades derived from one base color, e.g. for heatmaps
  • Multi-panel figures

    • Easy and flexible wrapper of matplotlib's GridSpec
    • Automatic labelling of sub-panels
    • Support for custom panel arrangements and labels
    • Figure sizes in inches, centimetres or millimetres

Credits

  • This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

  • Most color schemes are Paul Tol's, redistributed under the 3-clause BSD license

Download files

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

Source Distribution

spiffyplots-0.7.0.tar.gz (830.5 kB view details)

Uploaded Source

Built Distribution

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

spiffyplots-0.7.0-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file spiffyplots-0.7.0.tar.gz.

File metadata

  • Download URL: spiffyplots-0.7.0.tar.gz
  • Upload date:
  • Size: 830.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for spiffyplots-0.7.0.tar.gz
Algorithm Hash digest
SHA256 b9d595c492bdee4b2027c63b9ce771803d5e64709f83cd4e0c7b0427d15c7c5c
MD5 3dc013ac6c5f8f882d4ea3b904d8f345
BLAKE2b-256 d51562a2dbcdf65bd0a3c00c2235de6ef1baf72762c634b6f929508256770b64

See more details on using hashes here.

Provenance

The following attestation bundles were made for spiffyplots-0.7.0.tar.gz:

Publisher: publish.yaml on JRBCH/spiffyplots

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

File details

Details for the file spiffyplots-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: spiffyplots-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for spiffyplots-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b72f822cd4b8f33665b89a43b6fb616e0d17bd026260e21b1ce54791983e4431
MD5 61e27789c9d867fd6e0e6dbf945ca644
BLAKE2b-256 dcb5824beabdfdbbd7a9012324c1f183b01a9b4deb219e206f0e7b203a378e84

See more details on using hashes here.

Provenance

The following attestation bundles were made for spiffyplots-0.7.0-py3-none-any.whl:

Publisher: publish.yaml on JRBCH/spiffyplots

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.8.0

2 files

This release

0.7.0 This release

2 files

0.6.1

1 file

0.6.0

1 file

0.5.1

2 files

0.4.5

1 file

0.4.4

1 file

0.4.3

1 file

0.4.2

1 file

0.4.1

1 file

0.4.0

1 file

0.3.12

1 file

0.3.11

1 file

0.3.10

2 files

0.3.9

2 files

0.3.7

1 file

0.3.6

1 file

0.3.5

1 file

0.3.4

1 file

0.3.3

2 files

0.3.2

2 files

0.3.1

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