Reusable anywidget plot saver configurable with a config.toml.
Project description
plot-saver
plot-saver is a small reusable package for adding save buttons to Matplotlib figures in marimo notebooks.
It saves plots under a project results directory and can be configured with a project-level config.toml.
Installation
pip install plot-saver
or with uv:
uv add plot-saver
Config
plot-saver looks for a config.toml by searching upward from the current working directory.
All configuration keys are optional. If you do not provide a config.toml, or if you only provide some keys, plot-saver falls back to its built-in defaults.
The default output format is png.
You can override the defaults with a section like this:
[plot-saver]
format = "png"
default_label = "Save"
save_all_label = "Save all model plots"
empty_title = "No plots available"
empty_detail = "Render the notebook plots first."
saved_title = "Saved"
saved_many_title = "Saved {count} plots"
saved_error_title = "Saved with errors"
failed_title = "Could not save plots"
toast_detail_color = "#6b7280"
[plot-saver.theme]
radius = "8px"
padding_y = "0.45rem"
padding_x = "0.9rem"
font_size = "0.9rem"
light_border = "rgba(107, 114, 128, 0.35)"
light_background = "rgba(249, 250, 251, 0.95)"
light_text = "#111827"
light_hover_background = "rgba(243, 244, 246, 1)"
light_hover_border = "rgba(107, 114, 128, 0.55)"
light_disabled_background = "rgba(229, 231, 235, 0.9)"
light_disabled_border = "rgba(156, 163, 175, 0.35)"
dark_border = "rgba(156, 163, 175, 0.35)"
dark_background = "rgba(31, 41, 55, 0.95)"
dark_text = "#f3f4f6"
dark_hover_background = "rgba(55, 65, 81, 1)"
dark_hover_border = "rgba(209, 213, 219, 0.45)"
dark_disabled_background = "rgba(55, 65, 81, 0.8)"
dark_disabled_border = "rgba(107, 114, 128, 0.35)"
Usage
from pathlib import Path
import marimo as mo
import matplotlib.pyplot as plt
from plot_saver import make_plot_saver
fig, ax = plt.subplots()
ax.plot([0, 1, 2], [1, 3, 2])
save_plot = make_plot_saver(
mo,
results_dir=Path("results"),
config_path=None,
task_name="2AFC",
model_id="example-model",
)
button = save_plot(fig, "Example figure")
save_all = save_plot.save_all_widget()
Saved plots go to:
results/plots/<task_name>/<model_id>/
save_plot(fig, "Example figure") registers that figure and returns an individual save button for it.
save_plot.save_all_widget() returns a single button that saves every figure previously registered with that PlotSaver instance. This is useful in notebooks where you render several figures for the same task and model and want one action to export all of them together.
API
Main entry points:
make_plot_saver(...)save_button(...)save_figure(...)get_plot_save_format(...)find_project_config_path(...)
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
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 plot_saver-0.1.2.tar.gz.
File metadata
- Download URL: plot_saver-0.1.2.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
062bf43ed6f83634ed6795cf9abd8866b22d8d6d456c2ecb8bc47929392d25d1
|
|
| MD5 |
3aaa8e56feebff99118f8f4039f450f5
|
|
| BLAKE2b-256 |
08bf791359f5b48baa3bfe5f6b99cf91ea3e2bef1d45ecb671abc7f236056687
|
Provenance
The following attestation bundles were made for plot_saver-0.1.2.tar.gz:
Publisher:
publish.yml on javirm3/plot-saver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plot_saver-0.1.2.tar.gz -
Subject digest:
062bf43ed6f83634ed6795cf9abd8866b22d8d6d456c2ecb8bc47929392d25d1 - Sigstore transparency entry: 1283191499
- Sigstore integration time:
-
Permalink:
javirm3/plot-saver@96c302f078aece36f6152e42733f8bcd5ee61b96 -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/javirm3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96c302f078aece36f6152e42733f8bcd5ee61b96 -
Trigger Event:
release
-
Statement type:
File details
Details for the file plot_saver-0.1.2-py3-none-any.whl.
File metadata
- Download URL: plot_saver-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64bd19db49f61ceafec493fe4ef48a9d12439385f89080c63e92bbc2792a748e
|
|
| MD5 |
e4b1ac78b527413c3ef9f2f11ab00ea5
|
|
| BLAKE2b-256 |
d0085af4d3167017f89cfb8e7a1bf3579d9113a2f9e034a7836c80283870e90b
|
Provenance
The following attestation bundles were made for plot_saver-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on javirm3/plot-saver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plot_saver-0.1.2-py3-none-any.whl -
Subject digest:
64bd19db49f61ceafec493fe4ef48a9d12439385f89080c63e92bbc2792a748e - Sigstore transparency entry: 1283191508
- Sigstore integration time:
-
Permalink:
javirm3/plot-saver@96c302f078aece36f6152e42733f8bcd5ee61b96 -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/javirm3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96c302f078aece36f6152e42733f8bcd5ee61b96 -
Trigger Event:
release
-
Statement type: