How to Remove Tick Marks in Matplotlib

Recently, I was working on a Python data visualization project where I had to create a clean, presentation-ready chart for a U.S.-based client. The chart looked great, but the tick marks on both axes made it look cluttered.

That’s when I realized I needed to remove the tick marks in Matplotlib, not the labels, just the small lines that appear along the axes.

If you’ve been in a similar situation, don’t worry. In this tutorial, I’ll show you three simple ways to remove tick marks in Matplotlib using Python. I’ll also share a few extra tips to make your charts look professional and easy to read.

What Are Tick Marks in Matplotlib?

Before we start removing them, it’s important to understand what tick marks are.

In Matplotlib, tick marks are the small lines along the x-axis and y-axis that indicate where labels appear. They help identify data points on the chart, but sometimes, especially in minimalist or publication-ready charts, they can make the plot look busy.

Here’s an example of what tick marks look like in a basic Python Matplotlib plot.

import matplotlib.pyplot as plt

# Sample data
x = [1, 2, 3, 4, 5]
y = [10, 20, 25, 30, 40]

# Create a simple line plot
plt.plot(x, y, marker='o', color='royalblue')

# Add title and labels
plt.title("Sales Growth Over 5 Years (USA)", fontsize=14)
plt.xlabel("Year")
plt.ylabel("Sales (in $1000s)")

# Show the plot
plt.show()

In the chart above, you’ll notice small tick marks on both axes. These are what we’ll learn to remove next.

Method 1 – Use tick_params() in Python Matplotlib

One of the easiest ways to remove tick marks in Matplotlib is by using the tick_params() function.

This method gives you full control over both major and minor ticks, and you can easily turn them off with a single line of Python code.

Here’s how you can do it:

import matplotlib.pyplot as plt

# Data for demonstration
years = [2018, 2019, 2020, 2021, 2022]
sales = [150, 180, 220, 260, 310]

# Create a line plot
plt.plot(years, sales, color='darkgreen', marker='o', linewidth=2)

# Add labels and title
plt.title("Annual Sales in the USA (2018–2022)", fontsize=14)
plt.xlabel("Year")
plt.ylabel("Sales (in $1000s)")

# Remove both x and y tick marks
plt.tick_params(axis='both', which='both', length=0)

# Show the plot
plt.show()

You can refer to the screenshot below to see the output.

Remove Tick Marks in Matplotlib

In this code, the key part is plt.tick_params(axis=’both’, which=’both’, length=0). It sets the length of tick marks to zero, effectively removing them from the chart.

If you only want to remove tick marks from one axis, you can specify it like this:

  • axis=’x’ → removes tick marks from the x-axis
  • axis=’y’ → removes tick marks from the y-axis

This method is my go-to solution when I need a quick and clean chart.

Method 2 – Use set_xticks([]) and set_yticks([])

Another simple method to remove tick marks in Matplotlib is by setting the tick positions to an empty list.

This approach not only removes the tick marks but also the labels. It’s useful when you want a completely clean axis without any tick-related elements.

Here’s how it works in Python:

import matplotlib.pyplot as plt

# Example data
months = ["Jan", "Feb", "Mar", "Apr", "May"]
revenue = [120, 150, 170, 200, 240]

# Create a bar chart
plt.bar(months, revenue, color='skyblue')

# Add title and labels
plt.title("Monthly Revenue (USA)", fontsize=14)
plt.xlabel("Month")
plt.ylabel("Revenue (in $1000s)")

# Remove all tick marks and labels
plt.xticks([])
plt.yticks([])

# Show the plot
plt.show()

You can refer to the screenshot below to see the output.

How to Remove Tick Marks in Matplotlib

In this example, both the tick marks and their labels are removed. This method is perfect when you’re focusing on visual storytelling and don’t need numerical references on the axes.

Method 3 – Use ax.xaxis.set_ticks_position(‘none’)

If you’re working with Matplotlib’s object-oriented interface (which I often prefer for complex Python plots), you can use the Axes object to remove tick marks more precisely.

Here’s how you can do it:

import matplotlib.pyplot as plt

# Create a figure and axis object
fig, ax = plt.subplots(figsize=(7, 4))

# Sample data
years = [2017, 2018, 2019, 2020, 2021]
profits = [100, 120, 150, 180, 210]

# Create a line plot
ax.plot(years, profits, color='tomato', marker='o', linewidth=2)

# Add labels and title
ax.set_title("Company Profits (USA)", fontsize=14)
ax.set_xlabel("Year")
ax.set_ylabel("Profit (in $1000s)")

# Remove tick marks using the Axes object
ax.xaxis.set_ticks_position('none')
ax.yaxis.set_ticks_position('none')

# Show the plot
plt.show()

You can refer to the screenshot below to see the output.

Remove Tick Marks Matplotlib

Here, set_ticks_position(‘none’) removes the tick marks while keeping the labels intact. This method gives you fine-grained control over each axis, which is great for advanced Python visualizations.

Bonus Tip – Remove Tick Lines but Keep Labels

Sometimes, you might want to keep the tick labels but remove only the tick lines. This can make your chart look minimal while still preserving readability.

Here’s a quick example:

import matplotlib.pyplot as plt

# Example data
states = ["California", "Texas", "Florida", "New York", "Illinois"]
population = [39.5, 29.0, 21.5, 19.8, 12.8]

# Create a bar chart
plt.bar(states, population, color='orange')

# Add labels and title
plt.title("Population by State (in Millions)", fontsize=14)
plt.xlabel("State")
plt.ylabel("Population")

# Remove tick lines but keep labels
plt.tick_params(axis='both', which='both', length=0)

# Show the plot
plt.show()

This method is ideal when you’re preparing charts for reports or dashboards where clarity and aesthetics both matter.

When Should You Remove Tick Marks in Python Matplotlib?

From my 10+ years of experience working with Python and data visualization, I’ve learned that removing tick marks is not always necessary, but it’s often useful when:

  • You’re designing dashboards or infographics.
  • You want a minimalist or presentation-style chart.
  • You’re overlaying multiple plots and want to reduce visual clutter.
  • The tick marks don’t add much informational value.

However, if your chart is meant for data analysis rather than presentation, it’s usually better to keep tick marks for precision.

Common Mistakes to Avoid

While removing tick marks in Python Matplotlib is easy, here are some common mistakes I’ve seen people make:

  1. Removing both ticks and labels unintentionally:
    If you only want to remove the tick marks, don’t use plt.xticks([]) or plt.yticks([]) — these remove labels too.
  2. Forgetting to specify which axis:
    Always define axis=’x’, axis=’y’, or axis=’both’ in tick_params() for better control.
  3. Overusing minimalist design:
    While clean visuals look great, don’t sacrifice interpretability. Make sure your audience can still understand your chart easily.

Conclusion

So, that’s how you can remove tick marks in Matplotlib using Python.

We covered three easy and effective methods:

  1. Using tick_params() – the simplest and most flexible way.
  2. Using set_xticks([]) and set_yticks([]) – for completely clean axes.
  3. Using Axes methods – for advanced customization.

Personally, I use the tick_params() method most often because it gives me the perfect balance between simplicity and control.

You may like to read:

Leave a Comment

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.