I want to be able to ascertain the provenance of the figures I create using matplotlib, i.e. to know which version of my code and data created these figures. (See this essay for
If you are interested in PDF files, then you can have a look at the matplotlib module matplotlib.backends.backend_pdf
. At this link there is a nice example of its usage, which could be "condensed" into the following:
import pylab as pl
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
pdffig = PdfPages('figure.pdf')
x=np.arange(10)
pl.plot(x)
pl.savefig(pdffig, format="pdf")
metadata = pdffig.infodict()
metadata['Title'] = 'Example'
metadata['Author'] = 'Pluto'
metadata['Subject'] = 'How to add metadata to a PDF file within matplotlib'
metadata['Keywords'] = 'PdfPages example'
pdffig.close()