|
From: Alan G I. <ai...@am...> - 2005-07-22 19:15:05
|
On Thu, 21 Jul 2005, Rick Kwan apparently wrote: > I'm trying to produce a 2D plot of data points where the > X-axis represents a sequence of named events. A grid and > xticklabels have been enabled for clarity. > For a sample size of 11, all the points fall on the grid. For 12, > they do not. Beyond that seems to be on a case-by-case basis. > I'm sure I must be abusing the relationship between ticks and data, > but the proper solution eludes me. > from pylab import * > # top = 11 # 11 produces point on grid > top = 12 # 12 produces skewed data points > iter = [i for i in range(top)] > ax = subplot(111) > plot(iter, iter, 'gd-') > grid(True) > ax.xaxis.set_major_locator(LinearLocator(top)) > xlabs = ax.set_xticklabels(['evt%d'%i for i in range(top)]) > show() Count the gridlines. ;-) You are mislabeling the tics. (You might set the axes ranges explicitly to address this.) hth, Alan Isaac |