Skip to main content

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 files, buffers, or polars frames with column-attribute access (data.time, data.voltage)
  • Group rows by a tag column (TaggedData) or manage whole directories of data files (Dataset)
  • Plot multiple time series and mean-with-error graphs (standard deviation, standard error, variance, range)
  • Apply publication-ready matplotlib styles (SciencePlots): science, ieee, nature, notebook
  • 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/")
t, y = dataset.get_timeseries("position")
plot_mean_err(ax, t, y, "se", tlim=None, lw=1, 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

This project uses uv and nox:

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

MIT

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

pyplotutil-2.0.0.tar.gz (136.4 kB view details)

Uploaded Source

Built Distribution

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

pyplotutil-2.0.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file pyplotutil-2.0.0.tar.gz.

File metadata

  • Download URL: pyplotutil-2.0.0.tar.gz
  • Upload date:
  • Size: 136.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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

Hashes for pyplotutil-2.0.0.tar.gz
Algorithm Hash digest
SHA256 849f5ec9c71d37958d30ba69854c59903ce297f092a177ccfe5a2c78a34ff00a
MD5 fa880031dfe010fd12e2a4cabf24fb44
BLAKE2b-256 983be9bc3b4d034f7700a469400a418968c68e5a91c63de4a3d65470707cafc2

See more details on using hashes here.

File details

Details for the file pyplotutil-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyplotutil-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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

Hashes for pyplotutil-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d460b085fce1b4d61bbe0bce46addb38e2ffeab90be401f35e5e972ccc68e9d
MD5 30bd29cc069b0075240365536ee43373
BLAKE2b-256 cea11c3f428c70be743f90c3cf038e50e36ea83fdbbb7b919dae8d2debd1d24b

See more details on using hashes here.

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