> > This is in contrast to the effect of the following code: > > try: > from math import * > import pylab as p > except: > print "Couldn't import all dependent libraries" > sys.exit() > dataLength = 100 > data = [sin(2*pi*x/dataLength) for x in range(0,dataLength)] > p.plot(data) > newXTicks= [str(x/2.0) for x in p.xticks()[0]] > p.xticks(p.xticks()[0], newXTicks) > p.show() > > This code produces tick marks [0, 10, 20, 30, 40, 50]. However when > zooming, the xtick marks do not adjust correctly to the zoomed > regions. >
Setting the tick locations explicitly means that you want the mpl to stick to what you just provided and not to automatically adjust the tick locations. And that's the behavior you're seeing. Guessing from your code, it seems that you're fine with tick locations but want to change the format of the tick label. check the docmentation and also the example (custom_ticker1.py). http://matplotlib.sourceforge.net/api/ticker_api.html Here's what you may try: from matplotlib.ticker import FuncFormatter dataLength = 100 data = [sin(2*pi*x/dataLength) for x in range(0,dataLength)] p.plot(data) def label_half(x, pos): return str(x/2.) gca().xaxis.set_major_formatter(FuncFormatter(label_half)) p.draw() p.show() -JJ ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users