Skip to main content

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.

https://travis-ci.org/dfm/savefig.svg?branch=master

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.

Metadata

Release files for savefig 0.0.4

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

Source distribution (sdist)

Source distribution for savefig 0.0.4
File Size Uploaded Provenance Actions
savefig-0.0.4.tar.gz 4.5 kB Without provenance Details for savefig-0.0.4.tar.gz

Release files / savefig-0.0.4.tar.gz

Download URL savefig-0.0.4.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b90352b069774f79e3815fc96ed54883e2de30ea5edfed20d6a6367d0985e110
BLAKE2b-256 checksum
How to use checksums
38de794ff06eb3dbc3e95edb7d3a2a1dfe90c7415c982abae84cc3098f39048c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for savefig 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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