Skip to content
Snippets Groups Projects
figs2pdf.py 335 B
Newer Older
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.pyplot as plt


def figs2pdf(savename):
    """Save all open figures to a pdf file."""
    if "." not in savename:
        savename += ".pdf"
    with PdfPages(savename) as pp:
        for i in plt.get_fignums():
            plt.figure(i)
            pp.savefig()