<br><br><div class="gmail_quote">On Thu, Mar 10, 2011 at 4:04 AM, Mic J <span dir="ltr"><<a href="mailto:michael.cognacc@gmail.com">michael.cognacc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Hi i have a problem with passing a parameter to a function<br>
<br>
<br>
xtickvals = np.arange(0, total_project_days+5,  5)<br>
<br>
its for setting ticks on an axis, the x-axis<br>
<br>
Ex1: This works<br>
xticks = pylab.setp(ax2,<br>
xticklabels=['0','10','20','30','40','50','60','70','80','90','100'])<br>
<br>
Ex2: This doesnt work<br>
xticklabels=['0', '5', '10', '15', '20', '25', '30', '35', '40', '45', '50',<br>
'55', '60', '65']<br>
xticks = pylab.setp(ax2, xticklabels)<br>
<br>
I want to calculate how many tick is needed on that axis and then pass it to<br>
function.<br>
So that why i need something like the second example (or another way?)<br></blockquote><div><br>Mic,<br><br>The problem is that there is a difference between "positional" arguments and "keyword" arguments.  In the first example, the second argument is passed as a keyword argument (due to the equal sign).  This allows python to know which argument (by name) you want that value to be associated with.  However, in the second example, the second argument is given as a positional argument (due to the lack of an equal sign).  Python knows which argument (by position) you want that value associated with.<br>

<br>So, to make your second example work, just do this:<br><br>xticklabels=['0', '5', '10', '15', '20', '25', '30', '35', '40', '45', '50',<br>


'55', '60', '65']<br>xticks = pylab.setp(ax2, xticklabels=xticklabels)<br><br>That's it!<br><br>I hope this helps!<br>Ben Root<br><br></div></div>