Recently, while working on a Python data visualization project for a US-based retail analytics company, I needed to export a summary table created with Matplotlib into a clean, printable PDF format.
At first, I assumed there would be a direct function in Matplotlib to save tables as PDFs, but I quickly realized that the process required a few extra steps. So, I decided to document the entire workflow here, from creating a table in Matplotlib to saving it as a professional-looking PDF file.
In this tutorial, I’ll show you two simple methods you can use to save Matplotlib table as PDF in Python. Both methods are practical, easy to follow, and suitable for real-world projects.
Save a Matplotlib Table as a PDF
In many business and data analytics projects, especially in corporate environments across the USA, clients often request data summaries in PDF format.
Whether you’re preparing a monthly sales report, a financial summary, or a scientific data table, exporting your visualizations as PDFs ensures they are easily shareable and print-ready.
Method 1 – Save a Matplotlib Table as a PDF using savefig()
The simplest way to save a Matplotlib table as a PDF in Python is by using the savefig() function. This method works great when you only need to export a single table or figure.
Now, let’s create a simple table and save it as a PDF file.
Full Python Code Example
import matplotlib.pyplot as plt
# Step 1: Prepare the data
data = [
['California', 120000, 45000],
['Texas', 95000, 38000],
['New York', 110000, 42000],
['Florida', 87000, 36000],
['Illinois', 76000, 31000]
]
# Step 2: Define column labels
columns = ['State', 'Total Sales ($)', 'Profit ($)']
# Step 3: Create a figure and axis
fig, ax = plt.subplots(figsize=(6, 3))
ax.axis('off') # Hide the axes
# Step 4: Create the table
table = ax.table(cellText=data, colLabels=columns, loc='center')
# Step 5: Style the table
table.auto_set_font_size(False)
table.set_fontsize(10)
table.scale(1.2, 1.2)
# Step 6: Save the table as a PDF
plt.savefig('sales_summary.pdf', bbox_inches='tight')
print("PDF file saved successfully as 'sales_summary.pdf'")You can refer to the screenshot below to see the output.

In this code, I first created a dataset representing sales and profit data from five major US states. Then, I used ax.table() to generate a Matplotlib table and formatted it for better readability.
Finally, I used the plt.savefig() function to export it as a clean, high-resolution PDF file named sales_summary.pdf.
Tip
If you want the PDF to have a transparent background, you can add this parameter to the savefig() call:
plt.savefig('sales_summary.pdf', bbox_inches='tight', transparent=True)This is especially useful when embedding the table into reports or presentations.
Method 2 – Save Multiple Tables to a Single PDF using PdfPages
Sometimes, you may need to save multiple tables (or figures) into a single multi-page PDF file.
For example, if you’re generating monthly reports for different regions, you might want all of them in one document. In such cases, the PdfPages class from matplotlib.backends.backend_pdf is the perfect solution.
The idea here is simple: you create multiple figures (each containing a table) and then use PdfPages to save them all into one PDF file.
Full Python Code Example
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
# Step 1: Define data for multiple tables
data_usa = [
['California', 120000, 45000],
['Texas', 95000, 38000],
['Florida', 87000, 36000]
]
data_east = [
['New York', 110000, 42000],
['Massachusetts', 88000, 33000],
['New Jersey', 79000, 31000]
]
data_midwest = [
['Illinois', 76000, 31000],
['Ohio', 72000, 29000],
['Michigan', 69000, 27000]
]
columns = ['State', 'Total Sales ($)', 'Profit ($)']
# Step 2: Create a PDF file to store multiple pages
with PdfPages('regional_sales_report.pdf') as pdf:
# Page 1: USA Table
fig, ax = plt.subplots(figsize=(6, 3))
ax.axis('off')
table = ax.table(cellText=data_usa, colLabels=columns, loc='center')
table.auto_set_font_size(False)
table.set_fontsize(10)
table.scale(1.2, 1.2)
ax.set_title('West & South Region Sales Report', fontsize=12, pad=20)
pdf.savefig(fig, bbox_inches='tight')
plt.close()
# Page 2: East Region Table
fig, ax = plt.subplots(figsize=(6, 3))
ax.axis('off')
table = ax.table(cellText=data_east, colLabels=columns, loc='center')
table.auto_set_font_size(False)
table.set_fontsize(10)
table.scale(1.2, 1.2)
ax.set_title('East Region Sales Report', fontsize=12, pad=20)
pdf.savefig(fig, bbox_inches='tight')
plt.close()
# Page 3: Midwest Region Table
fig, ax = plt.subplots(figsize=(6, 3))
ax.axis('off')
table = ax.table(cellText=data_midwest, colLabels=columns, loc='center')
table.auto_set_font_size(False)
table.set_fontsize(10)
table.scale(1.2, 1.2)
ax.set_title('Midwest Region Sales Report', fontsize=12, pad=20)
pdf.savefig(fig, bbox_inches='tight')
plt.close()
print("Multi-page PDF created successfully as 'regional_sales_report.pdf'")You can refer to the screenshot below to see the output.

In this example, I created three separate tables, each representing a different US region. Then, I used the PdfPages class to combine all three tables into one PDF file named regional_sales_report.pdf.
Tip
You can mix tables and charts in the same PDF using this same approach. Simply create a plot using Matplotlib before calling pdf.savefig(fig).
Customize the Table Appearance
A well-formatted table not only looks professional but also improves readability. Here’s how you can customize your Matplotlib table in Python.
Example: Add Colors and Borders
import matplotlib.pyplot as plt
data = [
['California', 120000, 45000],
['Texas', 95000, 38000],
['New York', 110000, 42000]
]
columns = ['State', 'Total Sales ($)', 'Profit ($)']
fig, ax = plt.subplots(figsize=(6, 3))
ax.axis('off')
# Create the table
table = ax.table(cellText=data, colLabels=columns, loc='center')
# Style the header row
for (row, col), cell in table.get_celld().items():
if row == 0:
cell.set_facecolor('#1f77b4')
cell.set_text_props(color='white', weight='bold')
else:
cell.set_facecolor('#f2f2f2')
table.auto_set_font_size(False)
table.set_fontsize(10)
table.scale(1.2, 1.2)
plt.savefig('styled_sales_table.pdf', bbox_inches='tight')
print("Styled table saved successfully as 'styled_sales_table.pdf'")You can refer to the screenshot below to see the output.

In this version, I added a blue header row with white bold text and a light gray background for the data rows. This small tweak makes the table much more visually appealing, perfect for client-facing reports.
When to Use Each Method
| Use Case | Recommended Method |
|---|---|
| You only need to save one table | savefig() |
| You need multiple tables or charts in one file | PdfPages |
| You want to automate report generation | PdfPages |
| You need quick one-off exports | savefig() |
Common Errors and Fixes
| Error | Cause | Fix |
|---|---|---|
FileNotFoundError | Invalid file path | Use a valid directory path |
| Table not visible in PDF | Axis not turned off | Use ax.axis('off') |
| Blurry table | Low DPI | Use plt.savefig('file.pdf', dpi=300) |
Both methods, savefig() and PdfPages, work great for saving Matplotlib tables as PDFs in Python.
If you’re working on a single table, savefig() is quick and easy. But if you’re preparing multi-page reports or dashboards, PdfPages provides a professional, automated solution.
I use these techniques regularly when generating regional performance summaries or monthly analytics reports for clients. With just a few lines of Python code, you can create clean, shareable, and print-ready PDF reports directly from your data.
You may also read other tutorials on 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
- Save Multiple Pages to a PDF in Matplotlib

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.