Jürg W. Spaak
Jürg W. Spaak

Reputation: 2139

Issues with x-ticks in log-scale wit matplotlib

I have a figure in log-scale and would like to set the x-ticks manually to [0.5, 1, 2]:

import matplotlib.pyplot as plt

ax = plt.gca()

ax.set_xscale("log")
ax.set_xticks([0.5,1,2])
ax.set_xticklabels([.5,1,2])
ax.set_xlim([0.5,2]) # issue causing line

However, it automatically also sets one to 6*10^-1, which I can't get rid off. Even asking ax.get_xticks() doesn't show this x-tick. How can I get rid of the unwanted tick?

enter image description here

Upvotes: 1

Views: 737

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150725

That looks like a minor tick. Try adding

ax.set_xticks([], minor=True)

Output:

enter image description here

Upvotes: 2

Related Questions