iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Use ax.set_title() to label an individual subplot and fig.suptitle() to title the complete figure. They apply at different levels, so a multi-panel chart can use both: panel titles tell readers what each plot shows, while the suptitle gives the collection a shared context.
How to title each subplot and the whole figure
In Matplotlib, each subplot is an Axes object. Set its title with Axes.set_title(); set a title for the containing Figure with Figure.suptitle(). The Matplotlib gallery demonstrates both together with constrained layout.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 5, 501)
fig, (ax1, ax2) = plt.subplots(1, 2, layout="constrained", sharey=True)
ax1.plot(x, np.cos(6 * x) * np.exp(-x))
ax1.set_title("damped")
ax1.set_xlabel("time (s)")
ax1.set_ylabel("amplitude")
ax2.plot(x, np.cos(6 * x))
ax2.set_title("undamped")
ax2.set_xlabel("time (s)")
fig.suptitle("Different types of oscillations", fontsize=16)
plt.show()
Here, “damped” and “undamped” identify the individual panels; “Different types of oscillations” describes the figure as a whole. This pattern follows the Matplotlib gallery example for figure labels: Figure labels: suptitle, supxlabel, supylabel (Matplotlib 3.11.2 documentation).
Set a subplot title’s position and style
ax.set_title() accepts a loc argument to place a title at the "left", "center", or "right" of its Axes. For example, ax.set_title("Observed", loc="left") places the title on the left.
#1 Best Overall
The y argument sets the title’s vertical position, with 1.0 at the top of the Axes. If y is None, Matplotlib chooses the vertical location automatically to avoid Axes decorations. The pad argument controls the offset from the top in points; its documented default is 6.0. Use text-property keyword arguments such as fontsize or fontweight to style the title. The method returns a Matplotlib Text instance, and the API discourages using fontdict. See the Axes.set_title API (Matplotlib 3.11.1 documentation).
Position and style the figure suptitle
fig.suptitle() positions its text in figure coordinates. Its documented x and y defaults are 0.5 and 0.98, respectively. You can adjust them and choose horizontal or vertical alignment when the title needs a different position.
Rank #2
For text styling, pass properties such as fontsize and fontweight. By default, title size and weight follow the figure.titlesize and figure.titleweight settings. If you provide fontproperties, its defaults take the place of those figure settings. The call returns a Text instance. See the Figure.suptitle API (Matplotlib 3.11.2 documentation).
Manage spacing and align panel titles
Start with layout="constrained" when creating the figure if it has both panel titles and a suptitle. It is the layout approach used in Matplotlib’s gallery example, but it is not a guarantee that every combination of figure size, text, font, and output will fit without adjustment. Inspect the rendered chart and adjust the figure or title positions if they overlap or crowd the plots.
If titles should line up across a row of subplots, call fig.align_titles() when their positions are automatic and the Axes share a GridSpec relationship. The alignment persists across draw events after the method is called. The API describes these conditions in the Figure.align_titles API.
Use a title for a group of subplots
For a figure divided into groups, a SubFigure provides an intermediate level: its suptitle() can label one group, while the parent Figure can have its own overall suptitle. Matplotlib’s Figure subfigures example shows subfigures with their own titles alongside a parent figure title.
Which Matplotlib title method should you use?
| Title scope | Method | Use it for |
|---|---|---|
| One subplot | ax.set_title() |
A label for an individual Axes; choose left, center, or right placement. |
| One group within a figure | subfig.suptitle() |
A shared title for the Axes inside a SubFigure. |
| Entire figure | fig.suptitle() |
A shared title for all content in the Figure. |
The cited stable documentation pages are labeled Matplotlib 3.11.1 and 3.11.2; stable documentation and defaults may change between releases. Check the documentation for the Matplotlib version used by your project if exact behavior or defaults matter.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

