How to Change Matplotlib Title Font Size in Python

I’ve worked extensively with data visualization libraries, and Matplotlib remains one of my go-to tools. One common challenge I’ve faced is making sure the title of my plots is clear and readable, especially when preparing presentations or reports for clients in the USA. Changing the font size of the title can make a huge difference in how your visualizations are perceived.

In this article, I’ll walk you through simple yet effective ways to change the title font size in Matplotlib.

Let’s get started.

How to Adjust the Title Font Size?

Sometimes the default title size in Matplotlib is either too small to be noticeable or too large, overpowering the rest of the plot. Adjusting the font size ensures your title complements the data and fits well within your visualization layout.

For example, when presenting sales data for a US-based company, a clear, bold title like “2025 Quarterly Sales Performance” grabs attention immediately. But if it’s too small, your audience might miss it; too large, and it distracts from the data.

Method 1: Use the fontsize Parameter in plt.title()

The easiest and most direct way to change the title font size is by using the fontsize argument in the plt.title() function in Python.

Here’s how I usually do it:

import matplotlib.pyplot as plt

# Sample data for a US retail company’s monthly revenue
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May']
revenue = [25000, 27000, 29000, 31000, 33000]

plt.plot(months, revenue)
plt.title('Monthly Revenue for Q1 2025', fontsize=18)  # Set title font size to 18
plt.xlabel('Month')
plt.ylabel('Revenue ($)')
plt.show()

I executed the above example code and added the screenshot below.

matplotlib font size

In this example, fontsize=18 makes the title larger and more prominent. You can adjust this value to whatever suits your plot best.

Method 2: Use rcParams to Set Global Title Font Size

If you want all your plot titles to have the same font size without specifying it every time, you can configure Python Matplotlib’s global settings using rcParams.

Here’s how I set it up:

import matplotlib.pyplot as plt

plt.rcParams['axes.titlesize'] = 20  # Set global title font size

# Now, all titles will have fontsize 20 unless overridden
plt.plot(months, revenue)
plt.title('Monthly Revenue for Q1 2025')
plt.xlabel('Month')
plt.ylabel('Revenue ($)')
plt.show()

I executed the above example code and added the screenshot below.

plt title font size

This method is especially useful when you generate multiple plots in a report and want consistent styling across them.

Read Python Matplotlib tick_params

Method 3: Use set_title() Method on Axes Object

When working with object-oriented Matplotlib (which I highly recommend for complex plots), you can change the title font size with the Python’s set_title() method on an axes object.

Example:

fig, ax = plt.subplots()
ax.plot(months, revenue)
ax.set_title('Monthly Revenue for Q1 2025', fontsize=16)
ax.set_xlabel('Month')
ax.set_ylabel('Revenue ($)')
plt.show()

I executed the above example code and added the screenshot below.

matplotlib title font size

This approach gives you more control, especially when dealing with multiple subplots.

Method 4: Customize Font Properties with fontdict

If you want to customize not just the size but also the font family, weight, or style, you can pass a dictionary of font properties to the fontdict argument within plt.title() or set_title().

For example:

font_properties = {'fontsize': 22, 'fontweight': 'bold', 'family': 'serif'}

plt.plot(months, revenue)
plt.title('Monthly Revenue for Q1 2025', fontdict=font_properties)
plt.xlabel('Month')
plt.ylabel('Revenue ($)')
plt.show()

This method is handy when you want your titles to match specific branding or stylistic guidelines, such as those commonly used in US corporate presentations.

Tips for Choosing the Right Font Size

  • Consider your audience: For presentations to executives, larger and bolder titles work best.
  • Balance with plot size: Don’t let the title overpower the data visualization.
  • Test on different devices: What looks good on your monitor might be too small on a projector.
  • Use consistent styling: If you use multiple plots, keep title font sizes uniform for professionalism.

Check out Matplotlib Scatter Plot Legend

Conclusion

Changing the title font size in Matplotlib is straightforward but makes a significant impact on your plot’s readability and professionalism. Whether you prefer quick inline adjustments with fontsize, global settings with rcParams, or detailed control with set_title() and fontdict, these methods cover all common scenarios.

Next time you prepare a sales report or market analysis for your US-based team, remember that a clear, well-sized title can make your data story much more compelling.

This tutorial is designed to help you quickly master title font customization in Matplotlib and create polished, professional plots every time. Happy plotting!

You may also like to read the other tutorials on the topic of Matplotlib:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.