I plotted a graph in matplotlib, and it looks like this, where the x-axis ticks show correctly :
Here is my code:
import matplotlib
import matplotlib.pyplot as plt
fig1, ax1 = plt.subplots()
ax1.plot([1, 2, 3], [1,2,3])
ax1.set_xscale('log')
plt.xlim(1,100)
ax1.set_xticks([1,2,3,4,5,6,7,8,9,10])
ax1.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())
plt.show()
Then I adjusted the limits of the x-axis,
plt.xlim(1,10)
Here is the new code:
import matplotlib
import matplotlib.pyplot as plt
fig1, ax1 = plt.subplots()
ax1.plot([1, 2, 3], [1,2,3])
ax1.set_xscale('log')
plt.xlim(1,10)
ax1.set_xticks([1,2,3,4,5,6,7,8,9,10])
ax1.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())
plt.show()
And now there are some wrong numbers that I don't need:
How may I achieve the first graph as the small x-axis limits ?