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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To stop Matplotlib x-axis labels from colliding, show fewer tick labels with a locator or explicit tick positions; if every label must stay, rotate them or adjust their padding. To hide the text but keep tick marks, use labelbottom=False or a NullFormatter. To remove both ticks and labels, use ax.set_xticks([]).

Matplotlib has three separate things that are often called “labels”: tick positions, the text displayed at those positions, and the axis title set with set_xlabel. The examples below assume you already have an Axes object named ax.

Reduce crowding by showing fewer x-axis labels

Tick positions determine how many labels appear. When labels overlap, the most reliable fix is usually to display fewer of them rather than compressing all the text into the same space. Matplotlib locators choose tick positions, while formatters determine the text shown at those positions; see the Matplotlib guide to axis ticks.

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

Set explicit positions

For a fixed set of categories or observations, choose the positions you want labeled:

#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
ax.set_xticks([0, 5, 10, 15])

For example, if a plot has many sequential observations, labeling every fifth position can make the axis easier to read. Adjust the positions to match your data; the example is not a universal interval.

One caveat: set_xticks may expand the view limits so all supplied ticks are visible. If your intended limits matter, set them after the ticks:

ax.set_xticks([0, 5, 10, 15])
ax.set_xlim(0, 15)

See the Axes.set_xticks API.

Use a locator when positions should adapt

For changing data or interactive plots, use an appropriate locator through ax.xaxis.set_major_locator(...) so tick placement can respond to the current view limits. Choose a locator suited to the axis and data; the axis ticks guide explains the distinction between locators and formatters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Keep the labels but change their appearance

Rotation and padding affect the way labels are drawn, not how many tick positions Matplotlib uses. Set them across the x-axis with tick_params:

ax.tick_params(axis="x", labelrotation=45, pad=6)

labelrotation rotates the tick-label text; pad sets the distance between the labels and the axis. If angled labels need a different alignment, set their horizontal alignment:

plt.setp(ax.get_xticklabels(), ha="right")

A complete example with fewer labels, rotation, padding, and a layout adjustment:

Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot(values)
ax.set_xticks(range(0, len(values), 5))
ax.tick_params(axis="x", labelrotation=45, pad=6)
plt.setp(ax.get_xticklabels(), ha="right")
fig.tight_layout()

Here, values represents the data to plot. The five-position interval is an example to adapt to the data, not a Matplotlib requirement. The Axes.tick_params API documents label rotation, visibility, and other tick appearance settings.

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

Hide tick-label text while retaining tick positions

Use one of these approaches when tick marks or positions should remain but their text should not appear.

Hide labels on the bottom side

ax.tick_params(axis="x", labelbottom=False)

This turns off bottom x-axis label visibility without removing the tick locations or marks. It is useful when another subplot or annotation already provides the needed context.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Use a null formatter

from matplotlib.ticker import NullFormatter

ax.xaxis.set_major_formatter(NullFormatter())

A NullFormatter produces no tick-label text. Use it when you want to control the formatter rather than toggle label visibility; the Matplotlib ticker API documents this behavior.

Remove all x-axis ticks and labels

To remove both tick marks and their labels, pass an empty list:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ax.set_xticks([])

The Axes.set_xticks API states that an empty list removes all ticks.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Show labels only at the edges of a subplot grid

For a grid of plots, label_outer() suppresses interior labels while retaining labels on the outer edges. By default, x-axis labels are kept on the last row (or the first row when labels are positioned at the top):

for ax in axs.flat:
    ax.label_outer()

This assumes axs is the array of Axes objects returned by a subplot-creation function. See the Axes.label_outer API.

Remove the x-axis title, not the tick labels

If you mean the axis title—such as “Date” or “Temperature”—rather than the values beside the tick marks, clear the title with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ax.set_xlabel("")

This does not remove the tick labels. Use one of the tick-label methods above if the text beside the ticks is what you want to hide.

Choose the right approach

What you want Use What remains
Fewer labels to prevent overlap A locator or ax.set_xticks([...]) Tick marks and selected labels
All labels, angled or farther from the axis ax.tick_params(axis="x", labelrotation=..., pad=...) Tick marks and labels
No bottom label text, but keep ticks ax.tick_params(axis="x", labelbottom=False) Tick positions and marks
No major tick-label text NullFormatter() Tick positions and marks
No ticks or tick labels ax.set_xticks([]) The axis itself and plotted data
No axis title ax.set_xlabel("") Tick marks and tick labels

Avoid setting tick-label strings by themselves

Matplotlib marks set_xticklabels as discouraged in its Axes API. If you need custom labels for fixed positions, set the tick positions as well or use an appropriate formatter. For axes that can change or be interactively zoomed, prefer locators and formatters over editing individual tick artists; Matplotlib may recreate tick objects as the view changes.

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.