Metadata-Version: 2.4
Name: pltedit
Version: 0.1.2
Summary: Save and reload editable matplotlib figures as .plt files
License: MIT
Project-URL: Homepage, https://github.com/VForiel/PltEdit
Project-URL: Repository, https://github.com/VForiel/PltEdit
Keywords: matplotlib,figure,save,load,plot,edit
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: matplotlib>=3.5
Requires-Dist: numpy>=1.22
Provides-Extra: app
Requires-Dist: streamlit>=1.20; extra == "app"
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: matplotlib>=3.5; extra == "dev"
Requires-Dist: numpy>=1.22; extra == "dev"
Requires-Dist: streamlit>=1.20; extra == "dev"

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

## Overview

**PltEdit** 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:

```json
{
  "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

```bash
# Core library only
pip install pltedit

# With the Streamlit GUI
pip install pltedit[app]
```

## Usage

### Python API

```python
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()`:

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

### Streamlit GUI

```bash
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

```bash
git clone https://github.com/VForiel/PltEdit.git
cd PltEdit
pip install -e ".[dev]"
pytest
```
