Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsFor subplots that should appear together on one PDF page, save the Matplotlib Figure once with fig.savefig("subplots.pdf"). For a PDF with separate pages, use PdfPages and save one Figure per page.
Save all subplots together on one PDF page
plt.subplots() returns a Figure and its Axes. The Figure contains the complete subplot arrangement, so call savefig on the Figure—not on each Axes—to export the panels together. PDF is supported; Matplotlib’s documented default save format is PNG, so use a filename ending in .pdf or explicitly set format="pdf". See the Matplotlib savefig documentation.
import matplotlib.pyplot as plt
fig, axs = plt.subplots(2, 2, figsize=(8, 6))
axs[0, 0].plot([1, 2, 3], [1, 4, 9])
axs[0, 1].plot([1, 2, 3], [1, 2, 3])
axs[1, 0].bar(["A", "B"], [3, 5])
axs[1, 1].scatter([1, 2, 3], [3, 1, 2])
fig.savefig("subplots.pdf", format="pdf", bbox_inches="tight")
plt.close(fig)
bbox_inches="tight" trims the output to the figure’s tight bounding box and can help include labels or titles that extend beyond the default bounds. Because it can change the resulting page dimensions, inspect the PDF if a specific page size matters. It is optional; omit it when you need to preserve the figure’s ordinary page size.
Put multiple Figures on separate pages of one PDF
Use PdfPages when each page should contain a different Figure. A Figure may itself contain several subplots. Each call to pdf.savefig(fig) writes that Figure as a new page, as described in the PdfPages API.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
with PdfPages("report.pdf") as pdf:
for i in range(3):
fig, axs = plt.subplots(1, 2, figsize=(8, 4))
axs[0].plot([1, 2, 3], [i, i + 1, i + 2])
axs[1].bar(["A", "B"], [i + 1, i + 2])
fig.suptitle(f"Page {i + 1}")
pdf.savefig(fig, bbox_inches="tight")
plt.close(fig)
The with context manager closes and finalizes the PDF when the block ends, including when control exits because of an exception. Close each saved Figure in a loop to release pyplot-managed figures. You can also call pdf.savefig() to save the active Figure; passing fig explicitly makes clear which Figure is intended. The official multipage PDF example shows this workflow.
Choose the PDF structure that matches your output
| Output | Use | Result |
|---|---|---|
| One page containing several subplot panels | fig.savefig("subplots.pdf") |
One Figure, including its Axes, saved together on a page. |
| One PDF with several pages | PdfPages and repeated pdf.savefig(fig) calls |
Each saved Figure becomes a separate page; each Figure can contain multiple subplots. |
If the panels belong together as a single composite chart, use one Figure and save it once. If each page needs its own chart, title, or layout, create a Figure for each page and add it to the same PdfPages object.
Rank #2
Fix spacing and check the exported page
When titles, labels, or panels feel crowded, adjust the subplot margins and gaps on the Figure with fig.subplots_adjust(...). Matplotlib documents this method for controlling subplot spacing in the Figure.subplots_adjust reference.
fig.subplots_adjust(left=0.12, right=0.95, bottom=0.12, top=0.88,
wspace=0.35, hspace=0.4)
Increase the Figure size or adjust font sizes if labels remain difficult to read, then open the saved PDF and check that text is legible and nothing is clipped. Use bbox_inches="tight" only if trimming the bounding box is appropriate for your desired page dimensions.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Add optional PDF metadata
Metadata does not affect whether plots are included. If useful for a report, PdfPages accepts a metadata dictionary with fields such as Title, Author, Subject, Keywords, CreationDate, and ModDate; the supported API and an example are documented in the PdfPages reference and multipage PDF example.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




