Search code examples
pythonmatplotlibaxis-labels

Matplotlib delete plot stribes


I have the following issue displayed in the image below:problem

For an improved clarity I want do delete the stripes on the x axis or put them below the x axis. (Also it would be nice If you know a solution to the problem of overlapping numbers)


Solution

  • Assuming you have defined your plot and axes as below:

    import matplotlib.pyplot as plt
    fig, ax = plt.subplots()
    

    If you want to remove the x axis tick marks you can do:

    ax.tick_params(axis='x', top='off', bottom='off')
    

    If you want to change the direction of the tick marks you can do:

    ax.tick_params(axis='x', direction='out')
    

    If you want to change the x axis labels then use:

    set_xticklabels()
    

    You have to pass a list of labels to use, although I'm not sure why your labels aren't evenly spaced. The documentation at the link below should help:

    matplotlib.axes documentation