To change the title font size in Matplotlib, pass fontsize to the title function: plt.title("My title", fontsize=20), or ax.set_title("My title", fontsize=20) when you work with axes. The size can be a number of points or a name like "large". This guide covers the title font size for single plots and subplots, bold titles, the figure title (suptitle), changing it for every plot with rcParams, and the colorbar and legend title sizes.
Tested with Python 3.12.5 and Matplotlib 3.11.2; the charts are real Matplotlib windows. All text options are listed in the Axes.set_title documentation and the Text properties reference.
Change the title font size with plt.title()
import matplotlib.pyplot as plt
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
visitors = [1200, 1350, 1600, 1580, 1900, 2250]
plt.plot(months, visitors, marker="o")
plt.title("Website visitors per month", fontsize=20) # font size in points
plt.show()
plt.title(..., fontsize=20).fontsize and size are the same argument. Numbers are points (1 pt = 1/72 inch), so the title keeps its physical size when you change the figure size or DPI.
Title font size for subplots with ax.set_title()
With the object-oriented interface each axes has its own title. Set the size and weight per subplot:
import matplotlib.pyplot as plt
fig, axes = plt.subplots(1, 3, figsize=(10, 3.2))
for ax in axes:
ax.plot([1, 2, 3], [3, 1, 2])
axes[0].set_title("fontsize=10", fontsize=10)
axes[1].set_title("fontsize='x-large'", fontsize="x-large")
axes[2].set_title("Bold, size 16", fontsize=16, fontweight="bold")
plt.tight_layout()
plt.show()
fontweight="bold".Named font sizes and the default title size
Named sizes are relative to rcParams["font.size"] (10 pt by default). The default title size is "large", which is 12 pt. You can also read or change the size of a title after creating it with get_fontsize() and set_fontsize():
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
print("axes.titlesize =", plt.rcParams["axes.titlesize"])
print("figure.titlesize =", plt.rcParams["figure.titlesize"])
print("font.size =", plt.rcParams["font.size"])
print()
for name in ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"]:
print(f"{name:>9} = {FontProperties(size=name).get_size_in_points():5.2f} pt")
fig, ax = plt.subplots()
title = ax.set_title("Revenue")
print("\ndefault title size:", title.get_fontsize(), "pt")
title.set_fontsize(18) # change an existing title
print("after set_fontsize(18):", title.get_fontsize(), "pt")
Output:
axes.titlesize = large
figure.titlesize = large
font.size = 10.0
xx-small = 5.79 pt
x-small = 6.94 pt
small = 8.33 pt
medium = 10.00 pt
large = 12.00 pt
x-large = 14.40 pt
xx-large = 17.28 pt
default title size: 12.0 pt
after set_fontsize(18): 18.0 pt
Make the title bold
Add fontweight="bold" (or weight="bold"). Other accepted values include "normal", "light", "semibold", "heavy" or a number from 100 to 900:
plt.title("Quarterly revenue", fontsize=16, fontweight="bold")
ax.set_title("Quarterly revenue", fontsize=16, fontweight="bold")
Figure title font size with suptitle()
fig.suptitle() (or plt.suptitle()) adds one title above all subplots. It takes the same fontsize and fontweight arguments:
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1, 13)
fig, axes = plt.subplots(1, 2, figsize=(9, 4))
axes[0].plot(x, x * 12 + 50)
axes[0].set_title("Revenue", fontsize=12)
axes[1].plot(x, x * 3 + 20, color="tab:red")
axes[1].set_title("Costs", fontsize=12)
fig.suptitle("2025 financial summary", fontsize=18, fontweight="bold") # one title for the whole figure
plt.tight_layout()
plt.show()
Set the title font size for all plots with rcParams
To avoid repeating fontsize on every chart, set the defaults once at the top of the script (or in your matplotlibrc file):
import matplotlib.pyplot as plt
plt.rcParams["axes.titlesize"] = 16 # every ax.set_title() / plt.title()
plt.rcParams["axes.titleweight"] = "bold"
plt.rcParams["figure.titlesize"] = 20 # every fig.suptitle()
fig, axes = plt.subplots(1, 2, figsize=(9, 4))
axes[0].bar(["A", "B", "C"], [5, 7, 3])
axes[0].set_title("Orders") # no fontsize needed
axes[1].bar(["A", "B", "C"], [2, 4, 6], color="tab:green")
axes[1].set_title("Returns")
fig.suptitle("Set once with rcParams")
plt.tight_layout()
plt.show()
axes.titlesize, axes.titleweight and figure.titlesize apply to every new title.To change only one script’s figures temporarily, wrap the plotting code in with plt.rc_context({"axes.titlesize": 16}):.
Font family, color and position with fontdict
Group several font settings in a dictionary and pass it as fontdict. Use loc ("left", "center", "right") and pad to move the title:
import matplotlib.pyplot as plt
title_font = {"family": "serif", "size": 18, "weight": "bold", "color": "darkblue"}
plt.plot([2019, 2020, 2021, 2022, 2023, 2024], [3.1, 2.8, 3.6, 4.2, 4.0, 4.6])
plt.title("GDP growth (%)", fontdict=title_font, loc="left", pad=12) # loc and pad move the title
plt.show()
fontdict, loc and pad.Colorbar label and title font size
A colorbar is an axes of its own, so its text is set on the colorbar object:
cbar.set_label("text", fontsize=14)for the label along the bar,cbar.ax.set_title("text", fontsize=12)for a title above it,cbar.ax.tick_params(labelsize=10)for the tick numbers.
import matplotlib.pyplot as plt
import numpy as np
data = np.random.default_rng(7).normal(20, 5, size=(12, 12))
fig, ax = plt.subplots(figsize=(6.5, 5))
im = ax.imshow(data, cmap="coolwarm")
ax.set_title("Temperature map", fontsize=16)
cbar = fig.colorbar(im, ax=ax)
cbar.set_label("Temperature (°C)", fontsize=14) # label along the colorbar
cbar.ax.set_title("°C", fontsize=12, pad=8) # small title above the colorbar
cbar.ax.tick_params(labelsize=10) # colorbar tick numbers
plt.show()
Legend title font size
plt.legend() has its own title_fontsize for the legend title and fontsize for the entries:
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4], [10, 14, 12, 18], label="North")
plt.plot([1, 2, 3, 4], [8, 9, 13, 15], label="South")
plt.title("Sales by region", fontsize=16)
plt.legend(title="Region", title_fontsize=13, fontsize=11) # legend title and entries
plt.show()
title_fontsize=13 for the legend title.See these related Matplotlib text and label tutorials:
- Set and style the x-axis label in Matplotlib
- Change the legend font size
- Rotate tick labels in Matplotlib
- Stop large titles from overlapping with tight_layout()
Frequently asked questions
How do I change the title font size in Matplotlib?
Pass fontsize to the title call: plt.title("Title", fontsize=20) or ax.set_title("Title", fontsize=20).
How do I change the font size of ax.set_title()?
Use ax.set_title("Title", fontsize=14). For a title that already exists, call ax.title.set_fontsize(14).
How do I make a Matplotlib title bold?
Add fontweight="bold": plt.title("Title", fontweight="bold"). For all titles, set plt.rcParams["axes.titleweight"] = "bold".
How do I change the suptitle font size?
fig.suptitle("Title", fontsize=18), or set plt.rcParams["figure.titlesize"] for every figure.
What is the default title font size in Matplotlib?
axes.titlesize is "large", which is 12 pt with the default font.size of 10 pt. The suptitle default is also "large".
How do I change the colorbar label font size?
cbar.set_label("Label", fontsize=14) for the label and cbar.ax.tick_params(labelsize=10) for the tick numbers.
Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn