Working on a Python data visualization project where I needed to generate multiple charts and share them with my team in a single, printable PDF file. I tried saving each Matplotlib plot separately, but managing and sending multiple files quickly became messy.
That’s when I discovered a simple and powerful way to save multiple Matplotlib plots into one multi-page PDF. This method not only saves time but also keeps your visualizations organized and easy to share.
In this tutorial, I’ll show you how to save multiple Matplotlib plots into a single PDF file in Python. I’ll walk you through step-by-step examples using the PdfPages class from Matplotlib.
Save Multiple Matplotlib Plots to a Single PDF File
When working with Python and Matplotlib, you can easily save a single plot using plt.savefig(). However, if you want to save multiple plots into one PDF file, you’ll need to use the PdfPages class from the matplotlib.backends.backend_pdf module.
Here’s how it works: you create a PdfPages object, save each figure into it, and then close it when you’re done.
Let me show you the complete process.
Method 1 – Use PdfPages to Save Multiple Matplotlib Figures
This is the most common and efficient way to save multiple pages (plots) into a single PDF file in Python.
Below is the full working example.
# Import necessary libraries
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import numpy as np
# Create a PDF file to store multiple plots
pdf_filename = "multiple_plots_report.pdf"
# Use PdfPages as a context manager to ensure proper closure
with PdfPages(pdf_filename) as pdf:
# Generate multiple plots and save each to a new PDF page
for i in range(1, 6):
# Create a new figure for each plot
plt.figure(figsize=(8, 6))
x = np.linspace(0, 10, 100)
y = np.sin(x + i)
plt.plot(x, y, label=f"Plot {i}")
plt.title(f"Matplotlib Plot {i}")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.legend()
plt.grid(True)
# Save the current figure to the PDF
pdf.savefig()
plt.close()
print(f"All plots have been saved to '{pdf_filename}' successfully!")You can refer to the screenshot below to see the output.

In this Python code, I created five different plots using a simple sine wave function. Each figure is saved as a new page inside the same PDF file named multiple_plots_report.pdf.
You can open the resulting PDF to see all your visualizations neatly arranged on separate pages, perfect for reports or presentations.
Method 2 – Add Metadata to the Multi-Page PDF
Sometimes, I like to include metadata such as the author name, creation date, or title in my PDF reports. This can be easily done using the PdfPages object’s infodict() method.
Here’s how you can do it.
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import datetime
# Create a PDF file
with PdfPages("sales_report.pdf") as pdf:
# Add metadata to the PDF
d = pdf.infodict()
d['Title'] = 'Annual Sales Report'
d['Author'] = 'John Doe (Python Developer)'
d['Subject'] = 'Sales Performance Visualization'
d['Keywords'] = 'Python, Matplotlib, Sales, PDF'
d['CreationDate'] = datetime.datetime.today()
d['ModDate'] = datetime.datetime.today()
# Create multiple pages
for quarter in range(1, 5):
plt.figure(figsize=(8, 5))
x = ["Q1", "Q2", "Q3", "Q4"]
y = [20000, 24000, 22000, 26000]
plt.bar(x, y, color="skyblue")
plt.title(f"Quarterly Sales Data - {quarter}")
plt.xlabel("Quarter")
plt.ylabel("Revenue (USD)")
plt.grid(axis="y", linestyle="--")
pdf.savefig()
plt.close()
print("PDF with metadata created successfully!")You can refer to the screenshot below to see the output.

In this Python example, I used real-world sales data to create professional-looking quarterly charts. Adding metadata makes your PDF more descriptive and easier to manage, especially when generating reports for clients or teams.
Method 3 – Combine Existing Matplotlib Figures into One PDF
If you already have multiple Matplotlib figures created separately, you can still combine them into a single PDF without regenerating them.
This is useful when you generate plots in different parts of your Python application.
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import numpy as np
# Create multiple figures first
fig1, ax1 = plt.subplots()
x = np.linspace(0, 5, 100)
ax1.plot(x, np.exp(x), 'r-', label='Exponential')
ax1.legend()
ax1.set_title('Exponential Growth')
fig2, ax2 = plt.subplots()
ax2.plot(x, np.log(x + 1), 'g-', label='Logarithmic')
ax2.legend()
ax2.set_title('Logarithmic Growth')
# Combine both figures into one PDF
with PdfPages("combined_plots.pdf") as pdf:
pdf.savefig(fig1)
pdf.savefig(fig2)
print("Existing figures combined into one PDF successfully!")You can refer to the screenshot below to see the output.

This method is great when your plots are generated dynamically across different scripts or functions. You simply collect all the figure objects and save them together at the end.
Bonus Tip – Save Multiple Matplotlib Figures into a PDF Without Closing Them
Sometimes, I want to preview my figures before saving them. By default, plt.close() removes the figure from memory, but you can skip it if you want to keep it open.
Here’s an example:
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import numpy as np
pdf = PdfPages("open_figures.pdf")
for i in range(3):
fig, ax = plt.subplots()
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x + i)
ax.plot(x, y)
ax.set_title(f"Sine Wave {i+1}")
pdf.savefig(fig)
# Keep figures open for review
pdf.close()
plt.show()In this Python script, all figures remain open for review after saving. This is helpful when debugging or fine-tuning the appearance of your plots.
Save Multiple Matplotlib Plots into One PDF
Here are a few practical reasons why I prefer saving multiple plots into one PDF file in Python:
- Organization: Keeps all related visualizations in one place.
- Portability: Easy to share and print.
- Automation: Perfect for scheduled reporting scripts.
- Professional Presentation: Ideal for clients, stakeholders, or management reports.
In data analytics projects, especially when working with tools like Pandas and Matplotlib, this approach helps streamline reporting workflows.
Common Mistakes to Avoid
Even after years of working with Python and Matplotlib, I’ve seen developers make a few common mistakes when saving multi-page PDFs:
- Forgetting to close the PdfPages object: Always use a context manager (with PdfPages(…) as pdf:).
- Not calling pdf.savefig(): Simply creating a plot doesn’t save it; you must explicitly save each figure.
- Overwriting files accidentally: Use unique filenames or include timestamps to avoid overwriting existing reports.
- Large file sizes: If you’re saving high-resolution plots, consider reducing DPI or figure size.
By keeping these in mind, you can ensure smooth and efficient PDF generation.
So that’s how I save multiple Matplotlib plots into a single PDF file in Python. The PdfPages class makes it incredibly easy to generate professional, multi-page reports directly from your data visualizations.
Whether you’re a data analyst, researcher, or Python developer, this technique will save you time and help you create cleaner, more organized reports.
You may also like to read other articles on Matplotlib:
- Change the Colorbar Title Font Size in Matplotlib
- Change Matplotlib Figure Title Font Size in Python
- Save a Matplotlib Graph as a PDF in Python
- Save Matplotlib Subplots to PDF in Python

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.