Matplotlib's ticker module provides a few different ways of hiding ticks depending on your needs.
If you want to hide all the ticks along the x and y axes, you can do this by setting the ticks argument in your plotting command to an empty list like this:
plt.plot(x, y, ticks=[])
If you only want to hide specific ticks, you can do so using the ticker.IndexFormatter(). In this example we will hide tick labels associated with y values that are multiples of five:
import matplotlib.ticker as mticker
def format_fn(tick_val, tick_pos):
if int(tick_val) % 5 != 0:
return ''
else:
return int(tick_val)
ax.yaxis.set_major_formatter(mticker.FuncFormatter(format_fn))
If you want to hide only one side of the ticks, you can use the tick_params function. This example will hide the right and top axis ticks:
ax.tick_params(axis='x', right=False)
ax.tick_params(axis='y', top=False)
Hopefully this has answered your question about how to hide ticks in Matplotlib.