Vincent Vincent - 1 year ago 188
Python Question

Remove xticks in a matplot lib plot?

I have a semilogx plot and I would like to remove the xticks. I tried :


The grid disappear (ok), but small ticks (at the place of the main ticks) remain. How to remove them ?

Answer Source

The tick_params method is very useful for stuff like this. This code turns off major and minor ticks and removes the labels from the x-axis.

from matplotlib import pyplot as plt
    axis='x',          # changes apply to the x-axis
    which='both',      # both major and minor ticks are affected
    bottom='off',      # ticks along the bottom edge are off
    top='off',         # ticks along the top edge are off
    labelbottom='off') # labels along the bottom edge are off

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download