Home > Software engineering >  Issues with x-ticks in log-scale wit matplotlib
Issues with x-ticks in log-scale wit matplotlib

Time:10-29

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

CodePudding user response:

That looks like a minor tick. Try adding

ax.set_xticks([], minor=True)

Output:

enter image description here

  • Related