plotwright
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.
- Github repository: https://github.com/AdamHallengreen/plotwright/
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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| plotwright-0.1.1.tar.gz | 721.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| plotwright-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 741.2 kB
Release files / plotwright-0.1.1.tar.gz
| Download URL | plotwright-0.1.1.tar.gz |
|---|---|
| Size | 721.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe0fd2e7588e58031d5252b08ab80d2d48de4b2d4f36ef2601fd169beb21775f
|
|
BLAKE2b-256 checksum How to use checksums |
389fea3e652bf1a134f1057f72d045bbb070cb27e3cb4c96c1a235efab873eba
|
| 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.1-py3-none-any.whl
| Download URL | plotwright-0.1.1-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcc2feae18e2e6d9ab47c08f18ac1fc6d6ea4671a6cafdf4ab962008faadb983
|
|
BLAKE2b-256 checksum How to use checksums |
5a838cc77d51d61daa074ad5bca87886be016c29fa68c9f62c97098b3cf3eb60
|
| 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}
|