Reputation: 7451
I have a Python script which is producing a plot consisting of 3 subplots all in 1 column.
In the middle subplot, I currently have gridlines, but I want to remove the x axis tick labels.
I have tried
ax2.axes.get_xaxis().set_ticks([])
but this seems to remove the gridlines also.
How can I remove the tick labels and keep the gridlines please?
Upvotes: 0
Views: 1534
Reputation: 538
Please try this:
plt.grid(True)
ax2.axes.get_xaxes().set_ticks([])
Or maybe this:
from matplotlib.ticker import NullFormatter
ax2.axes.get_xaxis().set_major_formatter(NullFormatter())
Upvotes: 3