[Numpy-discussion] problem with array/ndarray/list parameter to function

Mic J michael.cognacc at gmail.com
Thu Mar 10 05:04:54 EST 2011

Hi i have a problem with passing a parameter to a function

xtickvals = np.arange(0, total_project_days+5,  5)

its for setting ticks on an axis, the x-axis

Ex1: This works
xticks = pylab.setp(ax2,

Ex2: This doesnt work
xticklabels=['0', '5', '10', '15', '20', '25', '30', '35', '40', '45', '50',
'55', '60', '65']
xticks = pylab.setp(ax2, xticklabels)

I want to calculate how many tick is needed on that axis and then pass it to
So that why i need something like the second example (or another way?)
I couldnt se code tags?

Code to calculate ticks and steps for output
#xticksval = np.arange(0, total_project_days+stpsz=5,  stepsz)
xtickvals = np.arange(0, total_project_days+5,  5)

# why do we need to define it here, instead of it being created in the for
xticklabels = []

for i in xtickvals:

xticks = pylab.setp(ax2, xticklabels)

The above code gives the same problem as example2

regards mic

More information about the NumPy-Discussion mailing list