From: Ryan M. <rm...@gm...> - 2009-08-04 19:49:05
|
On Tue, Aug 4, 2009 at 2:27 PM, Michael Droettboom <md...@st...> wrote: > > Gökhan Sever wrote: > >> >> I see a little change when I typed them in Ipython, however not exactly >> sure the real reasoning behind this. >> >> In [4]: lines = ax.plot(t, y1, lw=2, color='red', label='1 hz') >> >> In [5]: lines >> Out[5]: [<matplotlib.lines.Line2D object at 0xabce76c>] >> > Here the variable lines is a list with one element (a Line2D object). > >> >> In [6]: lines, = ax.plot(t, y1, lw=2, color='red', label='1 hz') >> >> In [7]: lines >> Out[7]: <matplotlib.lines.Line2D object at 0xabceaec> >> > Here lines is a Line2D object. > > ax.plot always returns a list because it may plot more than one line. The > choice of syntax for the caller of the function is just for convenience. > One could just as easily do: Yeah, it's a nice little feature of python: t = (1,2,3) x,y,z = t #Now: x=1, y=2, z=3 Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma Sent from Norman, Oklahoma, United States |