From: Michael D. <md...@st...> - 2009-08-04 19:27:53
|
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: lines = ax.plot(t, y1, lw=2, color='red', label='1 hz') line = lines[0] Cheers, Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |