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

Mic J michael.cognacc@gmail....
Thu Mar 10 04:04:54 CST 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,
xticklabels=['0','10','20','30','40','50','60','70','80','90','100'])

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
function.
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
loop
xticklabels = []

for i in xtickvals:
 xticklabels.append(str(i))

xticks = pylab.setp(ax2, xticklabels)
-----

The above code gives the same problem as example2

regards mic


More information about the NumPy-Discussion mailing list