Save and load matplotlib figures like MATLAB's .fig files!
Project description
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()
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()
Install
mplfig is on PyPI
pip3 install -U mplfig
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 mplfig-1.0.1.tar.gz.
File metadata
- Download URL: mplfig-1.0.1.tar.gz
- Upload date:
- Size: 77.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6046cf66da2d6064b7ad0567ac0ed4925d310a232bb7d86e11125fded26e86ad
|
|
| MD5 |
b25e6f293e2a4f719af113acb28dc224
|
|
| BLAKE2b-256 |
a920a397f5216f06d1f8b6020b217747cc11651efdfb9ab5e49d2903db884e18
|
File details
Details for the file mplfig-1.0.1-py3-none-any.whl.
File metadata
- Download URL: mplfig-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
222af51055337f327c06d7e8bc975f1ec230c7ffe0cc62b7a38b45f06ce3318f
|
|
| MD5 |
587fdc5976c652d6c2cb6800fc1602a2
|
|
| BLAKE2b-256 |
a4c10423c7954448f2bb582f7f41b528002f1a11d0089d88e01f283cdb19e6a6
|