3

If I run this code

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.xaxis.set_tick_params(length=0,labelsize=0)
ax.grid(True)

I get the following:

enter image description here

The xaxis ticks and labels don't show (as expected), but some dashes appear on the bottom of the plot (the first three of which I have circled in red).

How can I remove them? I have looked at the documentation for grids, but can't find anything.

An answer which teaches me how I could have figured out how to do this by looking at the documentation would be particularly useful.

ignoring_gravity
  • 6,677
  • 4
  • 32
  • 65
  • 1
    The first part of the question is answered [here](https://stackoverflow.com/a/20416681/2454357). The second part (how could you have figured that out yourself) is harder. Usually google and stackoverflow are your best friends :) – Thomas Kühn Feb 20 '18 at 14:24

1 Answers1

5

What you see are the ticklabels, which have size 0. Even zero sized ticks appear as a single dot because of antigraining.

You probably want to set the label off completely

ax.xaxis.set_tick_params(length=0,labelbottom=False)

You find out about this by looking at the available arguments in the documentation.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712