Matplotlib Remove Tick Labels

I’ve worked extensively with Matplotlib to create clear and effective data visualizations. One common task I often encounter is the need to remove tick labels from plots to improve readability or customize the appearance of charts.

Removing tick labels might seem trivial, but it’s a useful way to declutter your graphs, especially when presenting data to clients or stakeholders in the USA who expect clean, professional visuals.

In this article, I’ll walk you through several easy methods to remove tick labels in Matplotlib. Each method comes from my firsthand experience, so you’ll find them practical and easy to apply.

Method to Remove Tick Labels in Matplotlib

Now, I will explain to you the methods to remove tick labels in Matplotlib.

Method 1:Use `set_xticklabels` and `set_yticklabels` with Empty Lists

One of the simplest ways to remove tick labels is by setting them to an empty list. This effectively hides all the labels on the axis.

Here’s how I usually do it:

import matplotlib.pyplot as plt

# Sample data - US quarterly sales figures
quarters = ['Q1', 'Q2', 'Q3', 'Q4']
sales = [15000, 18000, 17000, 21000]

fig, ax = plt.subplots()
ax.bar(quarters, sales)

# Remove x-axis tick labels
ax.set_xticklabels([])

# Remove y-axis tick labels
ax.set_yticklabels([])

plt.show()

You can see the output in the screenshot below.

matplotlib remove ticks

This method is quick and intuitive. However, note that it removes only the labels, not the tick marks themselves.

Read Matplotlib Not Showing Plot

Method 2: Use tick_params to Hide Tick Labels

If you want more control, especially when you want to keep the ticks but hide their labels, tick_params is your friend.

Here’s how I use it:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4], [10, 20, 25, 30])

# Hide x-axis tick labels
ax.tick_params(axis='x', labelbottom=False)

# Hide y-axis tick labels
ax.tick_params(axis='y', labelleft=False)

plt.show()

You can see the output in the screenshot below.

remove ticks matplotlib

This method is very flexible. You can selectively hide labels on either axis without affecting the ticks or gridlines.

Check out Matplotlib Multiple Plots

Method 3: Remove Both Tick Labels and Tick Marks

Sometimes, you want a completely clean axis without any ticks or labels. You can achieve this by combining tick_params options:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([5, 10, 15, 20], [100, 200, 300, 400])

# Remove x-axis ticks and labels
ax.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)

# Remove y-axis ticks and labels
ax.tick_params(axis='y', which='both', left=False, right=False, labelleft=False)

plt.show()

You can see the output in the screenshot below.

matplotlib no ticks

This method is useful when you want to focus entirely on the data without any axis distractions.

Method 4: Use set_visible(False) on Tick Labels

If you prefer working directly with tick label objects, you can loop through them and set their visibility to False.

Here’s an example I often use when customizing plots:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([2, 4, 6, 8], [1, 3, 5, 7])

# Hide x-axis tick labels
for label in ax.get_xticklabels():
    label.set_visible(False)

# Hide y-axis tick labels
for label in ax.get_yticklabels():
    label.set_visible(False)

plt.show()

This approach gives you granular control, allowing you to selectively hide or show specific labels if needed.

Read Matplotlib Legend Font Size

Bonus Tips for Professional-Looking Plots

  • Preserve tick marks while hiding labels to maintain scale perception.
  • Use this technique in dashboards or reports where space is limited.
  • Combine with custom annotations to guide viewers without clutter.

Removing tick labels in Matplotlib is a small but essential skill that can significantly improve your visualizations. Whether you want a minimalist look or just need to clear up space, these methods will help you achieve that effortlessly.

You may like to read:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.