Python saving multiple figures into one PDF file

Use PdfPages to solve your problem. Pass your figure object to the savefig method.

For example, if you have a whole pile of figure objects open and you want to save them into a multi-page PDF, you might do:

import matplotlib.backends.backend_pdf
pdf = matplotlib.backends.backend_pdf.PdfPages("output.pdf")
for fig in xrange(1, figure().number): ## will open an empty extra figure :(
    pdf.savefig( fig )

Leave a Comment