A quick dirty solution would be the following:
ax.set_xticks(ax.get_xticks()[::2])
This would only display every second xtick. If you wanted to only display every n-th tick you would use
ax.set_xticks(ax.get_xticks()[::n])
If you don’t have a handle on ax
you can get one as ax = plt.gca()
.
Alternatively, you could specify the number of xticks to use with:
plt.locator_params(axis="x", nbins=10)