Course contentsShow
← Data Science
Lesson 1279 of 2,14532. Visualization with Matplotlib and SeabornFree lesson

Adding Overall Titles and Labels

Apply figure-level titles with suptitle() and create shared axis labels across multiple subplots.

Adding Overall Titles and Labels

You'll learn how to add figure-level titles and shared axis labels that span multiple subplots, making your multi-panel visualizations clearer and more professional.

When you create multiple subplots, each subplot can have its own title and axis labels. But what if you want a single title that describes the entire figure, or shared labels that apply to all subplots? That's where figure-level elements come in.

The Figure-Level Title with suptitle()

Think of suptitle() as the "master title" for your entire canvas. While each subplot can have its own title (using ax.set_title()), suptitle() creates a title that sits above all subplots, describing what the whole figure represents.

import matplotlib.pyplot as plt
import numpy as np

# Create subplots
fig, axes = plt.subplots(1, 2, figsize=(10, 4))

# Add a figure-level title
fig.suptitle('Sales Performance Q1 2024', fontsize=16, fontweight='bold')

# Individual subplot content
axes[0].plot([1, 2, 3], [4, 5, 6])
axes[0].set_title('Region A')

axes[1].plot([1, 2, 3], [6, 5, 4])
axes[1].set_title('Region B')

plt.tight_layout()
plt.show()

Shared Axis Labels

When your subplots share the same x or y axis meaning, you can add figure-level labels instead of repeating them on each subplot. Use fig.supxlabel() and fig.supylabel() to create these shared labels:

fig, axes = plt.subplots(2, 2, figsize=(8, 8))
fig.suptitle('Temperature Trends by City')
fig.supxlabel('Month')  # Shared x-axis label
fig.supylabel('Temperature (°C)')  # Shared y-axis label

# ... add subplot data ...
plt.tight_layout()
plt.show()

Key Takeaway: Use fig.suptitle() for overall figure titles and fig.supxlabel()/fig.supylabel() for shared axis labels across all subplots—this reduces redundancy and creates cleaner, more cohesive multi-panel visualizations.