October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober 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 Tick Label Font Size

Use Axes.tick_params to resize tick labels on an existing Matplotlib plot, or configure rcParams for plots created afterward.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To change tick-label font size on an existing Matplotlib plot, use ax.tick_params(axis='both', labelsize=14). Set axis='x' or axis='y' to change just one axis, or configure xtick.labelsize and ytick.labelsize for defaults on plots created afterward.

Change tick-label size on an existing plot

Axes.tick_params is the direct way to adjust tick appearance without replacing the tick labels. This example changes both axes to 14 points:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([1, 2, 3], [2, 4, 3])
ax.tick_params(axis='both', labelsize=14)
plt.show()

The labelsize argument accepts a numeric point size or a supported relative size such as 'large'. See the Matplotlib Axes API reference for the method details.

Set different sizes for the x- and y-axis labels

Call tick_params separately for each axis when the labels need different sizes:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ax.tick_params(axis='x', labelsize=12)
ax.tick_params(axis='y', labelsize=16)

Use axis='x' or axis='y' to target one axis; axis='both' applies the setting to both.

Set default sizes for later plots

To set defaults for plots created after the assignments, configure the x- and y-axis tick labels separately:

import matplotlib as mpl

mpl.rcParams['xtick.labelsize'] = 12
mpl.rcParams['ytick.labelsize'] = 12

Matplotlib documents xtick.labelsize and ytick.labelsize as the corresponding tick-label font-size settings; the documented default for each is 'medium'. The general font.size setting controls default text size, but these axis-specific settings are the direct controls for tick labels. For reusable project-wide styling, put the rcParams settings in a Matplotlib style configuration. The Matplotlib configuration reference explains rcParams and style sheets.

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

Why not use set_xticklabels or set_yticklabels?

Avoid calling ax.set_xticklabels(...) or ax.set_yticklabels(...) just to change font size. Those methods are discouraged for setting labels in the Axes API, and they change the label-setting behavior rather than simply adjusting appearance. Use tick_params for an existing Axes. In pyplot-based code, plt.xticks(fontsize=...) is another interface for the current axes; when you already have an Axes object, ax.tick_params(...) makes the target explicit. The pyplot API summary documents pyplot’s interface.

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

Choose the setting that matches your goal

Goal Use
Change both axes on one existing plot ax.tick_params(axis='both', labelsize=14)
Change only one axis, or give x and y different sizes Use axis='x' or axis='y'; make separate calls for separate sizes
Set defaults for plots created afterward Set mpl.rcParams['xtick.labelsize'] and mpl.rcParams['ytick.labelsize'], or use a style configuration

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.