Skip to main content

plotwright

Release Build status Commit activity License

A small matplotlib companion for consistent, presentable figures: a composable color/linestyle/ marker theme system, and a FigureSaver for exporting whole figures or single cropped subplots at a fixed, reproducible size.

Installation

pip install plotwright

or, with uv:

uv add plotwright

Quickstart

import matplotlib.pyplot as plt
from plotwright import FigureSaver, apply_theme

apply_theme("vibrant", base="paper")  # both are defaults; shown here for clarity

fig, ax = plt.subplots()
ax.plot([0, 1, 2], [0, 1, 4], label="series 1")
ax.legend()

FigureSaver("figures").save_figure(fig, "example.png")

apply_theme sets matplotlib rcParams for the rest of the session -- scope it to one figure with plt.rc_context() if you need more than one theme active side by side. FigureSaver handles writing figures to disk at a consistent size.

Palettes, bases, linestyles & markers

apply_theme(palette=, *, base=, linestyle=, marker=, ...) layers a base theme with a color cycle, and optionally a linestyle/marker cycle alongside it. Every name below is also available programmatically, so you're never guessing:

from plotwright import list_bases, list_palettes, list_linestyle_sets, list_marker_sets

list_bases()            # ('paper', 'presentation')
list_palettes()         # ('fishy', 'ggplot2', 'ibm', 'okabe_ito', 'petroff10', ...)
list_linestyle_sets()   # ('basic',)
list_marker_sets()      # ('basic',)
base= Use case
paper (default) Print/PDF figures -- compact, serif
presentation On-screen slides -- larger scale, sans-serif

Palettes (palette=): vibrant (default), fishy, ggplot2, ibm, okabe_ito, petroff10, seaborn_deep, tab10, tol_bright, tol_muted. Linestyle sets and marker sets (linestyle=/marker=): basic. Preview a palette's actual colors without applying it via palette_colors("vibrant").

Pass your own colors instead of a named palette with colors=[...] (a list of hex strings), and layer extra rcParams on top with extra_rc= (a dict, or a path to another .mplstyle file). See notebooks/demo.ipynb for a runnable tour of every option, including a side-by-side swatch of all palettes, sequential=, and latex=True.

Saving figures

saver = FigureSaver("figures", dpi=300)

saver.save_figure(fig, "whole_figure.png")                        # fixed size, no tight bbox
saver.save_subplot(fig, ax, "one_panel.png")                       # cropped to that axes' tight bbox
saver.save_subplots_aligned(fig, [ax1, ax2], ["a.png", "b.png"])   # cropped to a common width

Use mark_rasterized(*artists) to rasterize dense scatter/heatmap artists before saving to a vector format (pdf/eps/ps) -- keeps text and axes vector while the heavy artist becomes a bitmap.

Contributing

See CONTRIBUTING.md.

License

MIT -- see LICENSE.

Metadata

Release files for plotwright 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plotwright 0.1.3
File Size Uploaded
plotwright-0.1.3.tar.gz 721.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for plotwright 0.1.3
File Interpreter ABI Platform
plotwright-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 741.2 kB

Release files / plotwright-0.1.3.tar.gz

Download URL plotwright-0.1.3.tar.gz
Size 721.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b1102538af1905bea9ad93cc03738359de729a0dbfa0d8f6c0209df69589909b
BLAKE2b-256 checksum
How to use checksums
83d00e4856c16698ac4cf5e5cdf17187d6519f10def3074663926f0d2af322cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / plotwright-0.1.3-py3-none-any.whl

Download URL plotwright-0.1.3-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7551554a14d22d7ad478ac2282d01cc2cf71781a8ff3d4b3a6d339ed28ac7769
BLAKE2b-256 checksum
How to use checksums
438829ba6a5e8c9e6cfe42ee1509cce94ac1a70ad1b4a3e6fa23a1508dcdb7e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.1.4

2 release files

This release

0.1.3 This release

2 release files

0.1.1

2 release 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