In reality PdfPages is a thin wrapper around PdfFile, in order to avoid confusion when using savefig and forgetting the format argument.
Examples:
>>> import matplotlib.pyplot as plt>>> # Initialize:>>> with PdfPages('foo.pdf') as pdf:... # As many times as you like, create a figure fig and save it:... fig = plt.figure()... pdf.savefig(fig)... # When no figure is specified the current figure is saved... pdf.savefig()
Create a new PdfPages object.
Parameters:
filename: str or path-like or file-like
Plots using PdfPages.savefig will be written to a file at this location. The file is opened when a figure is saved for the first time (overwriting any older file with the same name).
metadata: dict, optional
Information dictionary object (see PDF reference section 10.2.1 ‘Document Information Dictionary’), e.g.: {'Creator': 'My software', 'Author': 'Me', 'Title': 'Awesome'}.
The standard keys are ‘Title’, ‘Author’, ‘Subject’, ‘Keywords’, ‘Creator’, ‘Producer’, ‘CreationDate’, ‘ModDate’, and ‘Trapped’. Values have been predefined for ‘Creator’, ‘Producer’ and ‘CreationDate’. They can be removed by setting them to None.