Matplotlib change xticks and retain xticks changing during zoom

dean.wheatley at gmail.com dean.wheatley at gmail.com
Thu Feb 19 22:34:32 EST 2009


Hello,

I execute 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)
p.show()


This produces a figure window. When I zoom in regions of the plot, the
xticks change correctly to the zoomed region.

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.


Your help on this issue would be great, thanks!



More information about the Python-list mailing list