Line up data points and xticklabels

ax.xaxis.set_major_locator(LinearLocator(top))

    > xlabs = ax.set_xticklabels(['evt%d'%i for i in range(top)])

LinearLocator(12) doesn't mean place ticks on the integers from 1-12
-- it says to make 12 linearly spaced ticks. If you know where you
want the ticks and what you want the labels to be, use

  xticks(locs,labels)

as in

from pylab import *

top = 11. # 11 produces point on grid
#top = 12. # 12 produces skewed data points
ind = arange(top)

ax = subplot(111)
plot(ind, ind, 'gd-')
grid(True)

labels = ['evt%d'%i for i in ind]
xticks(ind, labels)

show()

...

I knew there had to be an elegant solution. Thanks very much.
--Rick Kwan

···

On 7/22/05, John Hunter <jdhunter@...4...> wrote:

    > ax.xaxis.set_major_locator(LinearLocator(top))
    > xlabs = ax.set_xticklabels(['evt%d'%i for i in range(top)])

LinearLocator(12) doesn't mean place ticks on the integers from 1-12
-- it says to make 12 linearly spaced ticks. If you know where you
want the ticks and what you want the labels to be, use

  xticks(locs,labels)

as in