Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober 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

How to Share Axes and Axis Labels in Matplotlib Subplots

Set subplot sharing with sharex and sharey, manage tick labels with label_outer() or tick_params(), and add figure-wide labels with supxlabel() and supylabel().
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use sharex and sharey in plt.subplots() to coordinate subplot axes, then use fig.supxlabel() and fig.supylabel() for labels that belong to the whole figure. Choose a sharing mode that matches the comparisons your plots need: shared axes synchronize scale and limits, while independent axes let each panel use its own range.

Share axes when you create the subplot grid

Pass sharex and sharey to plt.subplots(). For a 2-by-2 grid that shares x within each column and y within each row:

As an Amazon Associate I earn from qualifying purchases.

import matplotlib.pyplot as plt

fig, axs = plt.subplots(
    2, 2,
    sharex="col",
    sharey="row",
    layout="constrained",
)

for ax in axs.flat:
    ax.plot([0, 1, 2], [0, 1, 0])
    ax.label_outer()

fig.supxlabel("Time")
fig.supylabel("Measurement")
plt.show()

This combines directional sharing, outer tick-label cleanup, and figure-wide labels. Adapt the sharing mode to the relationships among your data rather than applying one configuration to every grid. The current stable Matplotlib pyplot.subplots reference documents these options.

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

Choose a sharing mode that fits the comparison

Sharing is a scale and coordination choice, not just a way to reduce duplicate labels. Shared axes coordinate the relevant axis behavior and limits; Matplotlib’s shared-axis example notes that autoscaling considers data across shared Axes. This makes a common range useful when readers need to compare panels directly.

Setting What it shares When it can help
sharex=True or sharex="all" The x axis across all subplots Use when every panel should use a coordinated x axis.
sharey=True or sharey="all" The y axis across all subplots Use when every panel should use a coordinated y axis.
sharex="row" or sharey="row" The named axis within each row Use when panels in the same row should be coordinated.
sharex="col" or sharey="col" The named axis within each column Use when panels in the same column should be coordinated.
sharex=False or sharex="none"; likewise for sharey Nothing; each subplot’s axis remains independent Use when panels need different ranges or should not be coordinated.

The row and col modes are supported for either axis dimension. For example, vertical time-series panels often share x, while panels being compared across columns may share y—but the data and intended comparison should determine the choice. The stable API documents "all" as equivalent to True and "none" as equivalent to False.

Understand missing tick labels on shared axes

Matplotlib suppresses some tick labels by default when axes are shared, reducing repetition. With x axes shared in a column, only the bottom subplot’s x tick labels are created by default. With y axes shared in a row, only the first-column subplot’s y tick labels are created by default.

Keep only labels on the grid’s outer edges

Call label_outer() for each Axes to hide interior tick labels and retain those on the outside edges:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
for ax in axs.flat:
    ax.label_outer()

This is useful when the grid has several rows or columns and repeated labels would clutter the view.

Restore labels on a specific subplot

If an interior panel needs visible tick labels, enable them selectively with tick_params. For example:

axs[0, 0].tick_params(labelbottom=True)

Choose the relevant Axes and tick-label setting for the panel you want to restore. The shared-axis example documents both the default behavior and label controls.

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

Add one axis label for the whole figure

Use Figure.supxlabel() and Figure.supylabel(), usually called as fig.supxlabel("Time") and fig.supylabel("Measurement"). These add a shared x- or y-axis label at figure level rather than repeating the same label on every panel. Matplotlib’s figure-label example demonstrates them alongside shared axes.

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

Keep per-panel labels where panels represent different quantities or need distinct descriptions. A figure-wide label can describe a dimension common to the layout without implying that all panels contain identical data.

Plan sharing before building the figure

Matplotlib’s API states that shared axes cannot be unshared after creation. Set sharex and sharey in plt.subplots() when the grid is made. Custom sharing through Axes.sharex or Axes.sharey is also available, but it does not make sharing reversible.

The examples here follow the current stable Matplotlib documentation, which identified version 3.11.1/3.11.2 on October 4, 2026. Because the stable documentation alias can advance, check the API reference for your installed Matplotlib version if you are maintaining code on an older release.

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.

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

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
Windows Errors? Fix Them Before They SpreadFree repair scan
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.