DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk3 min

Matplotlib Subplot Titles and the Figure Suptitle

Use Axes titles to label individual panels and a Figure suptitle for the overall visualization. See examples for positioning, styling, layout, and nested plot groups.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use ax.set_title() to title an individual subplot and fig.suptitle() to title the complete figure. They label different levels of a Matplotlib visualization, so a figure with several panels can have both.

Title each subplot and the whole figure

Each subplot is an Axes object. Call its set_title() method to identify that panel; call the Figure object’s suptitle() method to describe the multi-panel figure as a whole. The Matplotlib gallery demonstrates the two together in its figure-labels example.

As an Amazon Associate I earn from qualifying purchases.

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()

In this example, “damped” and “undamped” identify the separate panels, while “Different types of oscillations” describes the figure’s comparison. The code follows the Matplotlib gallery pattern; layout="constrained" asks Matplotlib to account for the titles and other decorations when arranging the figure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a title location for an Axes

Axes.set_title(label, loc=...) supports center, left, and right locations. The method also accepts text properties such as fontsize and fontweight. Its y argument sets the vertical position in Axes coordinates, where 1.0 is the top of the Axes. If y is left as None, Matplotlib determines the position automatically to avoid Axes decorations. The documented pad default is 6.0 points. These details are from the Matplotlib 3.11.1 Axes.set_title API.

ax.set_title("Temperature", loc="left", fontsize=13, fontweight="bold")
ax.set_title("Station A", loc="right")

Each call sets the title at its requested location; use the location that helps readers distinguish panel context from a centered panel heading. The API discourages using fontdict; individual text-property keyword arguments are the preferred approach. set_title() returns a Matplotlib Text instance if you need to adjust the title afterward.

Position and style the figure suptitle

Figure.suptitle(t, ...) places a title in figure coordinates. The documented defaults for x and y are 0.5 and 0.98, respectively, which center the title near the top of the figure. Horizontal and vertical alignment, along with text styling, can be set in the call. Normally the size and weight follow the figure.titlesize and figure.titleweight settings. If you supply fontproperties, its defaults replace those figure rcParams defaults. See the Matplotlib 3.11.2 figure API for the documented parameters. The method returns a Text instance.

fig.suptitle("Quarterly results", x=0.5, y=0.99, fontsize=16, ha="center")

Handle spacing and aligned subplot titles

Start with a layout engine when combining an overall title, subplot titles, axis labels, and other decorations. Matplotlib’s gallery example uses layout="constrained", but that example is not a guarantee that every figure will fit at every size or with every font and backend. Inspect the rendered figure, especially after changing its dimensions or saving it at a different size; adjust the layout or title position if elements overlap.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When subplot-title positioning is automatic and the Axes share a GridSpec arrangement, fig.align_titles() can align titles in a row. The API says the Axes are expected to share a GridSpec relationship and that alignment persists across draw events after the method is called. Consult the Figure API for the method’s conditions.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Give a nested plot group its own title

For a larger figure organized into groups of plots, use Figure.subfigures() to create subfigures. A SubFigure can have its own suptitle(), while the parent Figure can retain an overall suptitle. This gives the title hierarchy three useful levels: panel titles on Axes, group titles on SubFigures, and a title for the complete Figure. Matplotlib demonstrates this arrangement in its Figure subfigures example.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.