Skip to main content

Save and reload editable matplotlib figures as .plt files

Project description

Plt-Edit

A simple tool to save matplotlib figures as a unique file and edit them afterward while keeping data integrity

Overview

Plt-Edit is a Python package that lets you save a matplotlib figure (or axes) — including all its underlying data — to a single .plt file, and reload it in another Python session or in a Streamlit-based GUI.

Unlike matplotlib's built-in savefig() (which exports to raster/vector image formats), a .plt file preserves the full figure object so it can be displayed, inspected, and edited programmatically.

File format

A .plt file is a NumPy archive (.npz) with a custom .plt extension. It contains two arrays:

Key Content
figure uint8 array — pickle-serialised matplotlib.figure.Figure
metadata 0-D object array — JSON string with creation info

The metadata JSON includes:

{
  "created_at": "2024-01-15T12:00:00+00:00",
  "python_version": "3.12.3 (main, ...)",
  "matplotlib_version": "3.10.1",
  "pltedit_version": "0.1.0"
}

Installation

# Core library only
pip install plt-edit

# With the Streamlit GUI
pip install plt-edit[app]

Usage

Python API

import matplotlib.pyplot as plt
import pltedit as plte

# Create a figure
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 5, 6], label="my data")
ax.set_title("My plot")

# Save to .plt
plte.save(fig, "my_figure.plt")

# Load in another session
fig2 = plte.load("my_figure.plt")

# Change style
fig2 = plte.set_style(fig2, "seaborn-v0_8")

# Display
fig2.show()

# Inspect metadata
from pltedit._io import get_metadata
meta = get_metadata("my_figure.plt")
print(meta["created_at"])

You can also pass an Axes object directly to save():

plte.save(ax, "from_axes.plt")

Streamlit GUI

pltedit                        # open the GUI (file upload)
pltedit path/to/figure.plt     # open the GUI with a pre-loaded file

The GUI lets you:

  • Upload any .plt file
  • View the stored figure metadata
  • Edit the figure title, axis labels, and axis limits interactively

Development

git clone https://github.com/VForiel/Plt-Edit.git
cd Plt-Edit
pip install -e ".[dev]"
pytest

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

pltedit-0.1.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

pltedit-0.1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file pltedit-0.1.0.tar.gz.

File metadata

  • Download URL: pltedit-0.1.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pltedit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b386a889ed6acc30fd6a6b841954804ac1fa46189f8b9eb12c14fac5739f2ad
MD5 5d15e9d8224e22ac7c42fd9506cf9104
BLAKE2b-256 f2a18649e84c17dd0e0bfdae26ee0468315fef5468027ce7d3fa9e5118a739cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pltedit-0.1.0.tar.gz:

Publisher: publish.yml on VForiel/PltEdit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pltedit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pltedit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pltedit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1ab5729453df9880e1e4c161e3afda337988000486e6a7cdaaa7575d74a73c6
MD5 33b17c19685e7967d3f2bd358b7cceaf
BLAKE2b-256 5518bb7bcf32d90f0c3de4b63ecd57bc897e59c3ff0101e17941bfe095040a7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pltedit-0.1.0-py3-none-any.whl:

Publisher: publish.yml on VForiel/PltEdit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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