Remove Tick Labels But Not Tick Marks But Preserve Distance Beween Ticks
I want to remove tick labels but keep the tick marks and keep my ticks consistently spaced. I have tried using both ax.tick_params(labelleft='off') and ax.set_yticks(np.arange(0,10
Solution 1:
You can set empty ticks to your plots like this:
y_ind = np.arange(0,100,10)
plt.yticks(y_ind,['']*len(y_ind))
If you do not want your y-axis to be scaled again, then you can set the y-axis scale:
plt.ylim((y_ind[0],y_ind[-1]))
Here is an example:
import matplotlib.pyplotas plt
import numpy as np
d1 = np.random.rand(100)
d2 = np.random.rand(100)
plt.subplot(2,1,1)
plt.plot(d1)
plt.xticks(np.arange(0,110,10),['']*11)
plt.xlim((0,100))
plt.subplot(2,1,2)
plt.plot(d2)
plt.xticks(np.arange(0,110,10),['']*11)
plt.xlim((0,100))
Post a Comment for "Remove Tick Labels But Not Tick Marks But Preserve Distance Beween Ticks"