python - pyplot: plotting x-axis in log scale spacing but not labeling it in exponential form -


i plot 2 values x = [0, 10,20,50,100] , y=[1,2,3,10,100] using pylab. want keep spacing of x-axis in log form. want tick @ values of x i'e @ 10, 20, 50, 100 , print them not in form of 10e1 or 10e2. doing follows:

 import matplotlib.pylab plt  plt.xscale('log')  plt.plot(x, y)  plt.xticks(x)  plt.grid() 

but keeps values in form of 10e1, 10e2.

could please me out?

i think want change major_formatter of x axis?

import matplotlib.pylab plt import numpy np matplotlib.ticker import scalarformatter  x = [0, 10,20,50,100] y=[1,2,3,10,100]  plt.plot(x, y) plt.xscale('log') plt.grid()  ax = plt.gca() ax.set_xticks(x[1:]) # note log axis, can't have x = 0 value isn't plotted. ax.xaxis.set_major_formatter(scalarformatter())  plt.show() 

scalar_formatter


Comments