In this short guide, we will learn how to remove tick labels from subplots in Python using Matplotlib — a common cleanup step when building clean dashboards, publication-ready charts, or minimal data visualizations.
1. Why Remove Tick Labels from Subplots?
When working with multiple subplots, tick labels (the numbers along the x and y axes) can clutter the chart — especially in grids where every subplot repeats the same scale. Removing them helps you:
- Create cleaner, less noisy visualizations
- Save space in tight subplot grids
- Match a minimal or professional design style
- Highlight the data shape rather than exact values
2. Steps to Remove Tick Labels from Subplots
- Import
matplotlib.pyplot - Create subplots using
plt.subplots() - Loop over axes using
axes.flatten() - Call
ax.set_xticklabels([])andax.set_yticklabels([])— or useax.tick_params() - Display or export the figure
3. Example Data
We'll use quarterly sales data for four well-known retailers — Walmart, Target, Costco, and Amazon — across four quarters.
quarters = ["Q1", "Q2", "Q3", "Q4"]
data = {
"Walmart": [120, 135, 128, 150],
"Target": [80, 90, 85, 100],
"Costco": [60, 70, 75, 85],
"Amazon": [200, 220, 215, 240],
}
4. Example: Remove Tick Labels Using set_xticklabels and set_yticklabels
The simplest way to hide tick labels on all subplots is to pass an empty list to set_xticklabels([]) and set_yticklabels([]) inside a loop.
import matplotlib.pyplot as plt
quarters = ["Q1", "Q2", "Q3", "Q4"]
data = {"Walmart": [120,135,128,150], "Target": [80,90,85,100],
"Costco": [60,70,75,85], "Amazon": [200,220,215,240]}
fig, axes = plt.subplots(2, 2, figsize=(8, 6))
for ax, (company, values) in zip(axes.flatten(), data.items()):
ax.bar(quarters, values, color="steelblue")
ax.set_title(company)
ax.set_xticklabels([])
ax.set_yticklabels([])
plt.tight_layout()
plt.show()
Output: Result:
A 2×2 grid of bar charts for Walmart, Target, Costco, and Amazon — all tick labels on both axes are completely removed, leaving clean, minimal bars with only the company name as the title.
5. Explanation of the Code
axes.flatten()— converts the 2D array of subplot axes into a flat list so you can loop over them easilyax.set_xticklabels([])— replaces x-axis tick labels with an empty list, hiding all labelsax.set_yticklabels([])— does the same for the y-axisax.set_title(company)— keeps the company name as the only label on each charttight_layout()— adjusts subplot spacing automatically
6. Bonus Example: Remove Only Tick Labels but Keep Tick Marks
Sometimes you want to keep the tick marks (the small lines) but hide only the text labels. Use ax.tick_params() with labelbottom=False and labelleft=False — a cleaner, more explicit approach.
import matplotlib.pyplot as plt
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
data = {"Google": [90,95,88,102,110,115], "Meta": [60,65,70,68,75,80],
"Netflix": [40,42,45,43,50,55], "Spotify": [20,22,25,24,28,30]}
fig, axes = plt.subplots(2, 2, figsize=(8, 6))
for ax, (company, values) in zip(axes.flatten(), data.items()):
ax.plot(months, values, marker="o")
ax.set_title(company)
ax.tick_params(labelbottom=False, labelleft=False)
plt.tight_layout()
plt.show()
Output: Result:
A 2×2 line chart grid for Google, Meta, Netflix, and Spotify — tick marks are still visible on each axis for visual reference, but all numeric labels are hidden, giving the grid a clean, uniform look.
7. Customization
| Goal | Code |
|---|---|
| Hide x labels only | ax.set_xticklabels([]) |
| Hide y labels only | ax.set_yticklabels([]) |
| Hide labels + ticks | ax.tick_params(bottom=False, left=False, labelbottom=False, labelleft=False) |
| Hide labels on one row only | Target specific axes: axes[0, 0].set_xticklabels([]) |
Use tick_params shortcut |
ax.tick_params(labelbottom=False, labelleft=False) |
Hide with plt.setp |
plt.setp(ax.get_xticklabels(), visible=False) |
Pro tip: In shared-axis grids, use plt.subplots(sharey=True, sharex=True) combined with tick label removal — this way inner subplots are clean while you can optionally keep labels only on the outer edges.