def set_xticks(start, step, axes="gca"):
    """
    This will generate a tick array and apply said array to the axis
    """
    if axes=="gca": axes = _pylab.gca()

    # first get one of the tick label locations
    yposition = axes.xaxis.get_ticklabels()[0].get_position()[1]

    # get the bounds
    xmin, xmax = axes.get_xlim()

    # get the starting tick
    nstart = int(_pylab.floor((xmin-start)/step))
    nstop  = int(_pylab.ceil((xmax-start)/step))
    ticks = []
    for n in range(nstart,nstop+1): ticks.append(start+n*step)

    axes.set_xticks(ticks)

    # set the y-position
    for t in axes.xaxis.get_ticklabels():
        x, y = t.get_position()
        t.set_position((x, yposition))

    _pylab.draw()
def set_xticks ( start , step , axes = "gca" ) : if axes == "gca" : axes = _pylab . gca ( ) yposition = axes . xaxis . get_ticklabels ( ) [ 0 ] . get_position ( ) [ 1 ] xmin , xmax = axes . get_xlim ( ) nstart = int ( _pylab . floor ( ( xmin - start ) / step ) ) nstop = int ( _pylab . ceil ( ( xmax - start ) / step ) ) ticks = [ ] for n in range ( nstart , nstop + 1 ) : ticks . append ( start + n * step ) axes . set_xticks ( ticks ) for t in axes . xaxis . get_ticklabels ( ) : x , y = t . get_position ( ) t . set_position ( ( x , yposition ) ) _pylab . draw ( )
This will generate a tick array and apply said array to the axis