saving

Saving matplotlib figures to file.

Reproducibility is a key requirement for publishing scientific work. As far as illustrations are concerned, reproducibility can be achieved using a VCS to track changes to the plotting code. When the CWD is in a git repository, the function save_fig() provided by this module stores the commit hash of HEAD in the “Creator” metadata of the saved figure. Some file formats are supported only through exiftool (see SUPPORTED_FORMATS and EXIFTOOL_FORMATS). The metadata can be retrieved e.g. via exiftool -Creator <filename(s)> or, for svg files, under the tag /svg/metadata/RDF/Work/creator/Agent/title.

Attributes

SUPPORTED_FORMATS

Default supported file formats for git revision.

EXIFTOOL_FORMATS

Exiftool supported file formats for git revision.

Functions

fig_dir(dest)

A context manager for temporarily changing the plotting directory.

get_fig_label(fig)

Returns a figure's label or, as a fallback, its number.

save_fig(fig[, dest, close])

Saves a figure and, optionally, closes it.