Skip to main content

mplfig

Matplotlib by default only allows you to export your figures in formats that are used for publishing (e.g., a .pgf file, a resterized .png file, etc.). MATLAB allows you to save files in a .fig format which allows you to change the plot very easily (say, to fix a typo on an axis label, or to change the colorscheme). mplfig strives to bring this functionality to matplotlib. With mplfig, you can save your matplotlib files and load them right back up in another python script.

Example

First, create a figure and save with it mplfig.

import mplfig
import matplotlib.pyplot as plt

xs = list(range(10))
ys = list(map(lambda x: x**2, xs))

plt.plot(xs, ys)
mplfig.save_figure(plt.gcf(), 'myfig.mplpkl')

plt.show()

Before

Next, load it back up and change the figure!

import mplfig
import matplotlib.pyplot as plt

fig = mplfig.load_figure('myfig.mplpkl') # Load the saved figure

axes = fig.get_axes()
axes[0].set_xlabel('$x$') # Add an x label
axes[0].set_ylabel('$y = x^2$') # Add a y label
axes[0].lines[0].set_marker('o') # Add a circle marker

plt.show()

After

Install

mplfig is on PyPI

pip3 install -U mplfig

Metadata

Release files for mplfig 1.0.1

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

Source distribution (sdist)

Source distribution for mplfig 1.0.1
File Size Uploaded
mplfig-1.0.1.tar.gz 77.0 kB Details

Built distribution (wheel)

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

Total release size: 81.5 kB

Release files / mplfig-1.0.1.tar.gz

Download URL mplfig-1.0.1.tar.gz
Size 77.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6046cf66da2d6064b7ad0567ac0ed4925d310a232bb7d86e11125fded26e86ad
BLAKE2b-256 checksum
How to use checksums
a920a397f5216f06d1f8b6020b217747cc11651efdfb9ab5e49d2903db884e18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / mplfig-1.0.1-py3-none-any.whl

Download URL mplfig-1.0.1-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
222af51055337f327c06d7e8bc975f1ec230c7ffe0cc62b7a38b45f06ce3318f
BLAKE2b-256 checksum
How to use checksums
a4c10423c7954448f2bb582f7f41b528002f1a11d0089d88e01f283cdb19e6a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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