VOOZH about

URL: https://www.geeksforgeeks.org/python/save-multiple-matplotlib-figures-in-single-pdf-file-using-python/

⇱ Save multiple matplotlib figures in single PDF file using Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Save multiple matplotlib figures in single PDF file using Python

Last Updated : 23 Jul, 2025

In this article, we will discuss how to save multiple matplotlib figures in a single PDF file using Python. We can use the PdfPages class's savefig() method to save multiple plots in a single pdf. Matplotlib plots can simply be saved as PDF files with the .pdf extension. This saves Matplotlib-generated figures in a single PDF file named Save multiple plots as PDF.pdf in the current working directory.

Installation

pip install matplotlib

Stepwise Implementation

To come up with a solution, we will follow a few steps.

Step 1: Import necessary files.

Step 2: Set up the figure size and adjust the padding between and around the subplots.

Step 3: We will consider 3 plots, so let's name them fig1, fig2, and fig3 using plt.figure().

Step 4: Plot the first line using the plt.plot() method.

Step 5: Create a function to save multiple images in a PDF file let's say save_image().

Complete Code 

Output:

Now after you run the code you can see on your local directory that a pdf containing all three plots will be saved in a pdf named "multi_plot_image.pdf".

👁 Image
 
👁 Image
 
👁 Image
 
Comment