How to set common axes labels for subplots
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When several Matplotlib subplots share the same meaning for the x-axis or y-axis, repeating labels on every subplot creates clutter. The cleanest modern solution is to set figure-level labels with fig.supxlabel() and fig.supylabel().
Use Figure-Level Labels
Matplotlib provides figure-wide axis labels for exactly this situation.
This keeps the subplot grid clean while still making the shared axes obvious.
Why This Is Better Than Repeating Labels
If every subplot repeats the same set_xlabel() and set_ylabel() text, the figure becomes harder to read. Common labels communicate the same information once at the figure level and free up visual space for the data.
This is especially helpful when:
- The subplots share the same units
- You are using
sharex=Trueorsharey=True - The figure contains several rows or columns
Fallback for Older Matplotlib Versions
If you are on an older Matplotlib version that does not support supxlabel and supylabel, you can place text manually on the figure canvas.
This older approach is still valid, but figure-level label methods are clearer when available.
Use Shared Axes Thoughtfully
Common labels pair naturally with shared axes:
That tells Matplotlib the subplot scales align, which makes common labeling more natural both visually and semantically.
Remove Redundant Axis Labels on Individual Plots
Common labels work best when the inner subplots do not all repeat their own labels. In many figures, you can leave per-axis labels off and rely on the figure-wide labels instead.
That small cleanup step is often what makes the final figure feel intentional instead of crowded.
Layout Still Matters
Even with figure-level labels, spacing can still be an issue. constrained_layout=True is often the easiest fix, but plt.tight_layout() or manual spacing can also help when a figure has titles, legends, or colorbars competing for room.
If the figure also has a suptitle, inspect the final render carefully. The title, shared labels, and subplot spacing all compete for canvas space, so small layout adjustments can make a noticeable difference in readability. Figure-level labels help, but they still need room to breathe. That final check is worth doing every time. A clean figure usually comes from several small layout choices working together. Common labels are one of those choices, not the whole story.
Common Pitfalls
- Figure-level labels work best when the subplots really do share the same axis meaning.
- Without layout management such as
constrained_layout=Trueortight_layout(), labels can overlap other figure elements. - Repeating axis labels on every subplot defeats the point of common labels.
- For older Matplotlib versions, use
fig.text()as a fallback instead of assumingsupxlabelexists.
Summary
- Use
fig.supxlabel()andfig.supylabel()for common axes labels in modern Matplotlib. - Combine them with shared axes when the subplots represent the same units and scales.
- Use
fig.text()as a fallback on older Matplotlib versions. - Figure-level labels usually make multi-plot figures cleaner and easier to read.

