Skip to main content

shplot

shplot is a Python library wrapper for managing Matplotlib configuration through profiles, and provides a number of built-in profiles suitable for different use cases.

Installation

shplot is available on PyPI, and can be installed with pip:

pip install shplot

Usage

Common use cases are shown here. Refer to the documentation for in-depth usage. The project repository's demos/ folder contains illustrations of the built-in profiles. The demo files can be (re)generated by running scripts/plot_demos.py.

Create a plot and use it in a context

>>> from shplot import ShPlot
>>> plot = ShPlot(builtin_profile_name="paper")
>>> with plot.context(nrows=2, ncols=2) as (fig, axs):
...     # `axs` is a 2x2 array.
...     pass
>>> with plot.context(mosaic="AAB\nC.B") as (fig, axs):
...     # `axs` is a dictionary.
...     pass

Update Matplotlib settings using a profile

>>> from shplot.profiles import ColorProfile
>>> profile = ColorProfile(fg="yellow", bg="black")
>>> profile.config()  # will update `matplotlib.rcParams`

Use a built-in profile with overrides

>>> from shplot import ShPlot
>>> from shplot.profiles.builtin import ShPaperProfile
>>> profile = ShPaperProfile(fontname="fira", **{"axes.grid": True})
>>> profile.config()

Create a plot using command line arguments

main.py

from shplot import ShPlot

plot = ShPlot.parse_from_cmdline()
with plot.context() as (fig, ax):
    ...
$ python main.py -h
usage: main.py [-h] [--file str] [--shprofile str] [--profile-args key=val,...] [--width
  float] [--aspect float[;float]]

options:
  -h/--help                   show this help message and exit
  --file str                  Plot save file (extension will be added if not provided).
                              (optional)
  --shprofile str             Name of a built-in profile.
                              ({paper/book/web_light/web_dark/presentation} optional)
  --profile-args key=val,...  Arguments for the builtin-profile. Refer to the individual
                              profiles for details. (optional)
  --width float               Plot width, in inches (if greater than 1), or as a fraction of
                              the configured plot width (if less than or equal to 1).
                              (optional)
  --aspect float[;float]      Plot aspect ratio, width/height. When provided as a command
                              line argument, can be passed as a single number or a ratio in
                              the form `<WIDTH>;<HEIGHT>`. (optional)

Metadata

Release files for shplot 1.0.0

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

Source distribution (sdist)

Source distribution for shplot 1.0.0
File Size Uploaded
shplot-1.0.0.tar.gz 27.2 kB Details

Built distribution (wheel)

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

Total release size: 43.6 kB

Release files / shplot-1.0.0.tar.gz

Download URL shplot-1.0.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f6396fcbcbbeb82e0055b905959100c44abb91c7015c3a411e09ebcdf1436736
BLAKE2b-256 checksum
How to use checksums
f8cb0ce629e3f0feb5257c9b08d814bc2fcf2819765480487dfcf2e538f12c39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1022-azure

Release files / shplot-1.0.0-py3-none-any.whl

Download URL shplot-1.0.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec928e8461a63edf10ed478f34a67180bd6440d502f788fd014c5bc615f53be8
BLAKE2b-256 checksum
How to use checksums
26807ba19721ddad524bc79b77ad6b98d4dda51e68299e72b6d7735b5243b8fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1022-azure

Release history Release notifications | RSS feed

This release

1.0.0 This release

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