Save matplotlib figures with embedded metadata for reproducibility and profit
Project description
Remember that time where you tried to remake a figure for your paper and couldn’t seem to get the same results? We’ve all been there. Well not anymore!
This module monkey patches the savefig command from matplotlib and inserts your current git commit hash into the metadata of the saved file. Currently it supports PNG and PDF figures.
Usage
First, install the module from PyPI:
pip install savefig
or from source:
git clone https://github.com/dfm/savefig.git cd savefig python setup.py install
Then in all your code just add the following lines before importing matplotlib:
from savefig import monkey_patch monkey_patch()
To read the metadata from an existing image file, run:
python -m savefig /path/to/figure.png
which will give you something like:
git-hash: 192a639c4a9eb7523e9becd23f359fd7d96e833f git-date: 2014-03-29 21:30:27 -0400 git-author: Dan F-M
You can also get the diff between the saved commit hash and the version used to make the figure by running:
python -m savefig /path/to/figure.png --diff
License
Copyright 2014 Dan Foreman-Mackey
Available under the MIT License.
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
File details
Details for the file savefig-0.0.2.tar.gz
.
File metadata
- Download URL: savefig-0.0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2881afe1943ab44635062f2c922b7d74cc3e4504df9c8c1d3f18f21610363e22 |
|
MD5 | 368c81cc7ceb0cce7a160fcc621f0ed4 |
|
BLAKE2b-256 | a001638389b5d53f23411ac774e8316df39395e524c83ca69ebe9422f16657dc |