If you have ever created a plot in Matplotlib, you know it automatically adds those tiny numbers and labels to your axes.
Usually, this is exactly what you want, but sometimes these labels just get in the way of a clean visual.
I have found that when I’m creating a high-level dashboard or a heat map where the data speaks for itself, removing the clutter makes the chart look ten times more professional.
In this tutorial, I will show you exactly how to turn off axis labels in Matplotlib using several different techniques I’ve used in my own projects.
Why You Might Want to Hide Axis Labels
In my experience, there are a few common scenarios where hiding labels is a better choice than keeping them.
If you are building a grid of subplots, you might only need the labels on the outer edges to avoid repeating the same information.
Another common case is when you are visualizing geographical data or images where the pixel coordinates aren’t as important as the visual itself.
Whatever your reason, Matplotlib gives us plenty of ways to handle this.
Method 1: Use plt.axis(‘off’) to Hide Everything
This is the “nuclear option” of hiding axes, and it is usually the first one I reach for when I want a completely clean canvas.
When you use this command, Matplotlib hides the labels, the tick marks, and even the border (the spines) of the plot.
I often use this when I’m plotting something like a logo or a specialized diagram where the frame isn’t needed.
import matplotlib.pyplot as plt
# US Tech Stocks - Mock Price Movement
days = [1, 2, 3, 4, 5]
prices = [150, 155, 153, 158, 162]
plt.plot(days, prices, color='navy', linewidth=2)
plt.title('Stock Performance Trend (Clean View)')
# Turn off the entire axis
plt.axis('off')
plt.show()You can refer to the screenshot below to see the output.

In the code above, the plt.axis(‘off’) command removes all the visual clutter instantly.
Method 2: Use tick_params to Hide Only the Labels
Sometimes, you want to keep the frame of the chart but just get rid of the numbers (the tick labels).
I find the tick_params method to be the most flexible because it lets you target a specific axis.
For example, if you are showing a bar chart of “Top US Cities by Population,” you might want to hide the Y-axis labels if the values are already written on top of the bars.
import matplotlib.pyplot as plt
cities = ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix']
values = [8.8, 3.9, 2.7, 2.3, 1.6] # Population in millions
plt.bar(cities, values, color='skyblue')
plt.title('Population of Top US Cities')
# Hide labels on both axes but keep the tick marks
plt.tick_params(left=True, bottom=True, labelleft=False, labelbottom=False)
plt.show()You can refer to the screenshot below to see the output.

This is great because you still see the small tick marks, which tell the viewer that data points exist, but the text is gone.
Method 3: Set Empty Lists for Ticks
Another trick I have used frequently is passing an empty list to set_xticks or set_yticks.
This essentially tells Matplotlib, “I don’t want any ticks here at all.”
It is a very explicit way to clear the axis, and I find it works perfectly when I am working with the Object-Oriented interface (using ax).
import matplotlib.pyplot as plt
# Monthly Revenue for a Seattle-based Startup (in thousands)
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May']
revenue = [45, 52, 49, 60, 58]
fig, ax = plt.subplots()
ax.plot(months, revenue, marker='o', color='darkgreen')
# Remove the X and Y axis labels and ticks entirely
ax.set_xticks([])
ax.set_yticks([])
ax.set_title('Revenue Growth (No Axis Distractions)')
plt.show()You can refer to the screenshot below to see the output.

By passing [], you are effectively clearing the data mapping from the visual axis.
Method 4: Use the set_visible(False) Method
If you are working with subplots and want to hide the axis for just one specific plot, set_visible(False) is your best friend.
I used this recently when I had a grid of four plots and wanted to hide the interior axes to save space.
This method is very clean because it treats the axis as an object that can just be “turned off” without affecting the rest of the figure.
import matplotlib.pyplot as plt
# US Energy Consumption Data (Sample)
labels = ['Renewable', 'Fossil Fuels', 'Nuclear']
sizes = [20, 60, 20]
fig, ax = plt.subplots()
ax.pie(sizes, labels=labels, autopct='%1.1f%%')
# Hide the axis object entirely
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
plt.title('US Energy Sources')
plt.show()You can refer to the screenshot below to see the output.

Note that for pie charts, Matplotlib often shows a frame by default; this method ensures it stays hidden.
Method 5: Use NullFormatter for Professional Results
For those who want to do things the “official” Matplotlib way, there is the NullFormatter.
This is a specialized tool that tells the axis formatter to simply return an empty string for every label.
I prefer this method when I’m writing production-level code because it doesn’t break any underlying logic about where the ticks are placed.
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
# Average Temperatures in Miami, FL
months = range(1, 13)
temps = [76, 78, 80, 83, 87, 89, 91, 91, 89, 86, 82, 78]
fig, ax = plt.subplots()
ax.plot(months, temps, color='orange')
# Use NullFormatter to hide labels but keep ticks
ax.xaxis.set_major_formatter(ticker.NullFormatter())
ax.yaxis.set_major_formatter(ticker.NullFormatter())
ax.set_title('Miami Temperature Trends')
plt.show()This keeps the tick marks perfectly placed but leaves the labels blank.
In this tutorial, I showed you five different ways to turn off axis labels in Matplotlib.
Whether you want to hide the entire axis or just the labels, these methods should cover every scenario you encounter.
I recommend trying plt.axis(‘off’) for quick cleanups and tick_params for more granular control.
You may read:
- How to Create Multiple Violin Plots in Matplotlib
- Matplotlib Multiple Circle Plots
- How to Change Matplotlib Tick Label Font Size
- Fix: import matplotlib.pyplot could not be resolved from source

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.