Skip to content

Instantly share code, notes, and snippets.

@milibopp
Last active December 17, 2019 21:29
Show Gist options
  • Save milibopp/79e082a0b9b4c24611ea to your computer and use it in GitHub Desktop.
Save milibopp/79e082a0b9b4c24611ea to your computer and use it in GitHub Desktop.
Matplotlib multiple pages in PDF
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
with PdfPages('multipage.pdf') as pp:
for i in range(0, 10):
fig = plt.figure()
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
x = np.linspace(0, 10)
ax1.plot(x, np.sin(x + i * np.pi / 10))
ax2.plot(x, np.cos(x + i * np.pi / 10))
pp.savefig(fig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment