October 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 ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Change Matplotlib Axis Label Font Size

Set a Matplotlib axis label’s font size directly with fontsize, or use axes.labelsize for a reusable default. Learn which settings control ticks and titles.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set fontsize on an axis-label method to change an x- or y-label without changing tick labels: ax.set_xlabel("Time", fontsize=14). The value is in points; 14 is an example, not a universal recommendation.

Change the font size for one plot

Use the Axes methods to set either label independently:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.set_xlabel("Time", fontsize=14)
ax.set_ylabel("Value", fontsize=14)

fontsize is a text property accepted by both label-setting methods. You can also use the pyplot convenience function for the current Axes:

plt.xlabel("Time", fontsize=14)

For subplots or code that works with a particular Axes, ax.set_xlabel and ax.set_ylabel make the target explicit. Pyplot calls such as plt.xlabel apply to the current Axes. See the Axes set_xlabel API, Axes set_ylabel API, and pyplot xlabel API.

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

Set a reusable default for axis labels

To apply a default size to x- and y-axis labels across plots, set axes.labelsize:

import matplotlib.pyplot as plt

plt.rcParams["axes.labelsize"] = 14

You can also put axes.labelsize in a matplotlibrc file or a style configuration. Matplotlib reads configuration at startup; see the customization guide. The stable rcParams reference lists the default as medium. It lists axes.labelpad separately for label spacing, with a default of 4.0 points.

Choose the setting for the text you mean

Axis labels, tick labels, and the Axes title have separate settings. Changing axes.labelsize changes x/y axis labels, not the tick labels or title.

Text element Setting
X- and y-axis labels axes.labelsize
X tick labels xtick.labelsize
Y tick labels ytick.labelsize
Axes title axes.titlesize
General default text size font.size

The customization guide documents 10 pt as the standard font.size value and points to the more specific settings for specialized text. Numeric font sizes are point sizes; Matplotlib text settings also accept named relative sizes. For a figure-wide label, use the Figure-level supxlabel or supylabel API rather than assuming axes.labelsize controls it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the version when exact defaults matter

The official stable documentation cited here identifies Matplotlib 3.11.2 for the rcParams, customization, and pyplot xlabel pages; the Axes API index identifies 3.11.1. Documentation defaults may change between releases, so check the installed Matplotlib version if exact defaults or behavior matter.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

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.