Dawei Wang
Dawei Wang

Reputation: 174

Remove xtick and ytick but keep grid

I'm trying to remove the xtick and ytick so that the final diagram looks like below. I want to keep the guide lines so that it would be easier for referencing. However, in Matplotlib, once you remove the xtick or ytick using the ax.set_xticks([]) or ax.set_yticks([]) method, the grid also disappears. Is there a way to make the plt.grid() function not infer from the xticks or yticks? Any suggestion is much appreciated! Thanks!

enter image description here

Upvotes: 0

Views: 81

Answers (1)

Scott Boston
Scott Boston

Reputation: 153510

Try setting the visibilty:

xticklines = ax.get_xticklines()
for i in xticklines:
    i.set_visible(False)

Upvotes: 1

Related Questions