Metadata-Version: 2.4
Name: matplotedit
Version: 1.0.0
Summary: Save Matplotlib figures as editable .mpe desktop files.
Home-page: https://github.com/tanuj163/matplotedit
Author: Tanuj Gupta
License: MIT
Project-URL: Source, https://github.com/tanuj163/matplotedit
Project-URL: Issues, https://github.com/tanuj163/matplotedit/issues
Keywords: matplotlib,figure,editor,pyqt,visualization,matlab
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
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: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: Matplotlib
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib>=3.5
Requires-Dist: numpy>=1.21
Requires-Dist: PyQt6>=6.5
Requires-Dist: Pillow>=9.0
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# MatPlotEdit

Editable MATLAB `.fig`-style desktop files for Matplotlib.

`matplotedit.save(fig, "plot.mpe")` stores the Matplotlib figure as a portable JSON
schema. `matplotedit open plot.mpe` launches a PyQt6 desktop editor where you can
pan/zoom, edit titles, labels, limits, scales, trace colors, visibility, and
export to PNG/SVG/PDF.

## Install

From PyPI:

```bash
pip install matplotedit
```

From this folder:

```bash
pip install -e .
```

If PyQt6 is not already installed, the command above installs it with the
package dependencies.

## Save A Figure

```python
import matplotlib.pyplot as plt
import matplotedit

fig, ax = plt.subplots(figsize=(8, 5))
ax.plot([1, 2, 3, 4], [2, 4, 1, 6], label="Series A", color="#e94560")
ax.scatter([1, 2, 3, 4], [1, 3, 5, 2], label="Points", color="#0f8fff")
ax.set_title("Demo")
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.legend()
ax.grid(True)

matplotedit.save(fig, "demo.mpe", open_after=True)
```

## Open A File

```bash
matplotedit open demo.mpe
```

or:

```python
import matplotedit
matplotedit.open_viewer("demo.mpe")
```

## Inspect Metadata

```bash
matplotedit info demo.mpe
```

## Desktop Editor Features

- Matplotlib navigation toolbar: pan, zoom, reset, configure, save image.
- Figure editor: title, size, DPI, background color.
- Figure size controls include numeric inputs and sliders for width, height,
  and DPI.
- Selected plot box controls let you resize/reposition the active subplot and
  change that subplot's background color independently. The active plot is
  shown and selectable directly in the Figure tab.
- Axes editor: title, X/Y labels, X/Y limits, linear/log scales, grid toggle,
  font family, tick font size, title font size, label font size, and explicit
  X/Y tick values.
- Axis label position controls let you move the X/Y labels in axes coordinates.
- Grid editor: major grid, minor grid, color, alpha, line style, and line width.
- Legend editor: visibility, title, font family, font size, frame, location,
  and X/Y anchor. Legends are also draggable inside the figure. A dragged
  legend keeps priority across redraws and figure-size edits until you choose
  Use Code Location.
- Trace editor: label, color, line width, alpha, visibility.
- Marker editor: marker type, size, fill color, edge color, edge width, and
  marker alpha for line/scatter plots.
- Line/patch editor: line style, draw style, line width, bar edge color, and
  bar hatch where those properties apply.
- Text editor: add/delete custom text with data-position, font family, font
  size, color, rotation, visibility, and direct dragging in the plot.
- Default text styling is Times New Roman, 18 pt for generic Matplotlib fonts.
- Data inspector: hover near a point to read X/Y values, click near a point to
  pin a callout on the figure. Line, scatter, and bar data are supported.
- Zoom out: use the toolbar Home button, the toolbar Back button, or View >
  Reset View / Zoom Back.
- Direct editing: double-click an axes title, X label, Y label, tick label, or
  legend to jump to the matching editor field.
- Figure-layout pan: View > Pan Figure Layout moves all axes boxes together.
- File menu: open, save, save as, export PNG/SVG/PDF.

## Test Everything

```bash
python test_all_plots.py
python test_plot_types_separate.py
matplotedit open MatPlotEdit_all_plots.mpe
matplotedit open MatPlotEdit_matlab_style.mpe
```

## Backward Compatibility

Older `.mpe` files created as self-contained HTML still load. The new default
format is JSON because it is better suited to a desktop app.

To keep generating the old browser file:

```python
matplotedit.save_html(fig, "demo.html")
# or
matplotedit.save(fig, "demo.mpe", legacy_html=True)
```

## Supported Plot Types

| Matplotlib call | Desktop rendering |
| --- | --- |
| `ax.plot()` | Line |
| `ax.scatter()` | Scatter |
| `ax.bar()` | Bar |
| `ax.imshow()` | Image |
| `ax.annotate()` | Annotation |
| Multiple axes | Multiple Matplotlib axes |

## Build A Windows App

Install PyInstaller:

```bash
pip install pyinstaller
```

Build an executable launcher:

```bash
python -m PyInstaller --name MatPlotEdit --windowed --collect-all PyQt6 --collect-all matplotlib matplotedit\__main__.py
```

The executable will be created under `dist\matplotedit`.


