Reputation: 333
I would like to remove the numerical values in each thick of my y-axis (10, 20, 30, etc.) but keeping the thick marks and the axis label. So far I just have:
yticks([])
but it removes the ticks as well. I also tried:
frame=gca()
frame.axes.get_yaxis().set_visible(False)
but it removes both axis label and axis ticks.
Upvotes: 3
Views: 19163
Reputation: 61
I agree with Mathieu that tick_params() is a better method (because you don't need to know the number of ticks in advance), however the most generalized parameter is "label1On," i.e.:
gca().tick_params(axis='x',label1On=False)
This approach easily extends to 'y' axis, as well as the second 'x' or 'y' axes (using label2On).
Upvotes: 3
Reputation: 31
The tick_params()
function should do the job:
gca().tick_params(axis='x',labelbottom='off')
Upvotes: 3
Reputation: 16119
You can set the tick labels to an empty list:
from matplotlib.pyplot import *
gca().set_xticklabels(['']*10)
plot(range(10))
Results in
I had to do that before I called plot
. Not sure why the other way around didn't work
Upvotes: 1