Python utilities for academic plotting
Project description
pyplotutil: plotting utility for academic publications
pyplotutil is a wrapper library of polars and matplotlib, which allows you to handle time series data easily and create graphs tolerable to scientific publications.
Features
- Load tabular data from CSV, Parquet, JSON/NDJSON, or Excel files,
buffers, or polars frames with column-attribute access
(
data.time,data.voltage) - Group rows by a tag column (
TaggedData,load_tagged_data) or manage whole directories of data files (Dataset) - Plot multiple time series and mean-with-error graphs (standard deviation, standard error, variance, range, confidence interval)
- Plot directly from data objects: one line per file for a
Dataset, one labeled line per tag forTaggedData - Apply publication-ready matplotlib styles
(SciencePlots):
science,ieee,nature,notebook - Annotate plotted lines with boxed labels and arrows
(
annotate_with_arrow) and add direction arrowheads along trajectories (add_direction_arrows) - Highlight time spans from boolean masks (
shade_spans) and configure axes cosmetics in one call (setup_axes) - Save figures to multiple formats in one call with sanitized filenames
- Event logging helpers with file and console output
Installation
Requires Python 3.11+.
pip install git+https://github.com/hrshtst/pyplotutil.git
Interactive plotting with plt.show() needs a GUI backend, which is
provided by the optional gui extra:
pip install "pyplotutil[gui] @ git+https://github.com/hrshtst/pyplotutil.git"
Quickstart
import matplotlib.pyplot as plt
from pyplotutil import Data, Dataset, apply_style, plot_mean_err, save_figure
# Publication-ready style.
apply_style("science", no_latex=True)
# Load a single CSV file; columns are accessible as attributes.
data = Data("experiment.csv")
fig, ax = plt.subplots()
ax.plot(data.t, data.position)
# Load every CSV file in a directory and plot mean with standard error.
dataset = Dataset("results/")
plot_mean_err(ax, dataset, "position", "se", capsize=2, label="mean")
# Write figure.png and figure.pdf in one call.
save_figure(fig, "output", "figure", ["png", "pdf"])
Group rows by a tag column:
from pyplotutil import TaggedData
tagged = TaggedData("trials.csv", tag_column="trial")
for tag, data in tagged:
print(tag, data.param("gain"))
Development
uv sync # set up the development environment
uv run pytest # run the test suite
uv run mypy # type check
uv run ruff check # lint
nox # lint + type check + tests on Python 3.11-3.14
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 pyplotutil-2.1.0.tar.gz.
File metadata
- Download URL: pyplotutil-2.1.0.tar.gz
- Upload date:
- Size: 159.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bc05add4f66723864c5f357db1aa17b6283e9030d05c15652f191fd847719a7
|
|
| MD5 |
12813a72a5d048b83c5f73b1b99dd4b8
|
|
| BLAKE2b-256 |
29465ccd17615b959c9fe66e6dd17ea9b6198288dd1415a1dad0f72e80ff1fc4
|
File details
Details for the file pyplotutil-2.1.0-py3-none-any.whl.
File metadata
- Download URL: pyplotutil-2.1.0-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bb958cdb000f68df9cedf0bee1874c6462e7793efd6bcaa2ea42f7f1ae5884d
|
|
| MD5 |
58a2f1c42678725c3372b1f4358ffed2
|
|
| BLAKE2b-256 |
4add002e578426c3abaf7fc65a7161974712085f4c4b9e3e675ba19c41c917c2
|