Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavincangan/46ba3f2d9097c431b1043e97fb2baece to your computer and use it in GitHub Desktop.
Save gavincangan/46ba3f2d9097c431b1043e97fb2baece to your computer and use it in GitHub Desktop.
from matplotlib.backends.backend_pdf import PdfPages
def multipage(filename, figs=None, dpi=200):
pp = PdfPages(filename)
if figs is None:
figs = [plt.figure(n) for n in plt.get_fignums()]
for fig in figs:
try:
fig.savefig(pp, format='pdf')
except:
print('At least one of the figures could not be saved to PDF')
pp.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment