JeanS
JeanS

Reputation: 75

How to replace ticks in Matplotlib?

I would like to change the ticks intervals on a figure, which looks like that:

enter image description here

I use this:

plt.xticks(np.arange(1945, 2016, 10))

However, what I finally get is:

enter image description here

As you can see, I can't take out the smaller ticks. I tried this line:

ax.tick_params(axis='x', length=0)

But without success, since it show this:

enter image description here

I lost the ticks I would like to plot.

To plot, my code is:

for row, plot in enumerate(toplot):
for col, country in enumerate(countries):
    ax = axes[row][col]
    (dx[(plot, country)]
     .plot(ax=ax, c=color)
     )

Any idea?

Upvotes: 0

Views: 141

Answers (1)

duburcqa
duburcqa

Reputation: 1131

It looks like what you want to do is disable the "minor ticks". Here you can find the official documentation about it, and another thread on stackoverflow about it. I did not try it myself bu just adding ax.minorticks_off() should do the trick !

Upvotes: 1

Related Questions