Python plot log scale set xticks?
Question: I am trying to plot between in Log scale but there are problems ;

    
    
    from pylab import *
    import matplotlib.pyplot  as pyplot
    
    Ds = pow(10,5)
    D = np.linspace(0, pow(10,6), 6)
    alpha=1.44
    beta=0.44
    A=alpha*pow((D/Ds), beta)
    L=1.65
    a=exp(-(A*L/4.343))
    fig = pyplot.figure()
    ax = fig.add_subplot(1,1,1)
    ax.set_xscale('log')
    xlim(0.001,1)
    ylim(0.1,1)
    ax.grid()
    line, = ax.plot(D/(Ds),a, color='blue', lw=2, marker='o')
    show()
    

but I can not set the value labels of x axis and ticks for it.I want y axis to
show between 0 to 1 with 0.1 increments ; x axis to show between 0 to 10 in
logscale like 0.001 0.002 0.003 0.004 0.005....0.01 0.02 0.03 ... and so on
but I can not do it ?

set_xscale automates the ticks and value labels.Any idea ?


Answer: Yes, you can do it like:

    
    
    import numpy as np
    xticks = [0.001, 0.002, 0.003, 0.004, 0.005, 0.01, 0.02, 0.03, 0.04, 0.05,
              0.1, 0.2, 0.3, 0.4, 0.5, 1., 2., 3., 4., 5., 10.]
    yticks = np.arange(0,1,0.1)
    ax.xaxis.set_ticks( xticks )
    ax.yaxis.set_ticks( yticks )
    

To force labels in all given positions you can you the `set_ticklabels()`
method, where you can also control the string format:

    
    
    ax.xaxis.set_ticklabels( ['%1.e'  % i for i in xticks] )
    ax.yaxis.set_ticklabels( ['%1.1f' % i for i in yticks] )
    

