unexpected exception

Hi!
I'm a newbie of matplotlib, and I'm trying to plot a set of data... but I
got blocked...

$ cat matplotliberr.py
#!/usr/bin/env python

# dummy data to plot
from datetime import date, timedelta
from random import randint
x = [ date.today() + timedelta(i) for i in range(10) ]
y = [ randint(0, i) for i in range(10) ]

from matplotlib import pyplot
pyplot.fill(x, y) # no problem using pyplot.plot(x, y)
pyplot.show()
$ ./matplotliberr.py
/usr/lib/python2.6/site-packages/pytz/tzinfo.py:5: DeprecationWarning: the
sets module is deprecated
  from sets import Set
Traceback (most recent call last):
  File "./matplotliberr.py", line 10, in <module>
    pyplot.fill(x, y)
  File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 1876,
in fill
    ret = gca().fill(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 5558, in
fill
    for poly in self._get_patches_for_fill(*args, **kwargs):
  File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 394, in
_grab_next_args
    for seg in self._plot_2_args(remaining, **kwargs):
  File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 331, in
_plot_2_args
    func(x, y)
  File "/usr/lib/python2.6/site-packages/matplotlib/axes.py", line 314, in
makefill
    (x[:,np.newaxis],y[:,np.newaxis])),
TypeError: list indices must be integers, not tuple
$ rpm -q python-matplotlib
python-matplotlib-0.98.5.2-1.3

···

--
By ZeD

Vito De Tullio wrote:

Hi!
I'm a newbie of matplotlib, and I'm trying to plot a set of data... but I
got blocked...

$ cat matplotliberr.py
#!/usr/bin/env python

# dummy data to plot
from datetime import date, timedelta
from random import randint
x = [ date.today() + timedelta(i) for i in range(10) ]
y = [ randint(0, i) for i in range(10) ]

from matplotlib import pyplot
pyplot.fill(x, y) # no problem using pyplot.plot(x, y)

Try fill_between instead of fill. Fill does not support units (arguments that are not simple number sequences), but fill_between does; in addition, I think fill_between is what you really want here.

Eric

···

pyplot.show()
\./matplotliberr\.py /usr/lib/python2\.6/site\-packages/pytz/tzinfo\.py:5: DeprecationWarning: the sets module is deprecated &nbsp;&nbsp;from sets import Set Traceback \(most recent call last\): &nbsp;&nbsp;File &quot;\./matplotliberr\.py&quot;, line 10, in &lt;module&gt; &nbsp;&nbsp;&nbsp;&nbsp;pyplot\.fill\(x, y\) &nbsp;&nbsp;File &quot;/usr/lib/python2\.6/site\-packages/matplotlib/pyplot\.py&quot;, line 1876, in fill &nbsp;&nbsp;&nbsp;&nbsp;ret = gca\(\)\.fill\(\*args, \*\*kwargs\) &nbsp;&nbsp;File &quot;/usr/lib/python2\.6/site\-packages/matplotlib/axes\.py&quot;, line 5558, in fill &nbsp;&nbsp;&nbsp;&nbsp;for poly in self\.\_get\_patches\_for\_fill\(\*args, \*\*kwargs\): &nbsp;&nbsp;File &quot;/usr/lib/python2\.6/site\-packages/matplotlib/axes\.py&quot;, line 394, in \_grab\_next\_args &nbsp;&nbsp;&nbsp;&nbsp;for seg in self\.\_plot\_2\_args\(remaining, \*\*kwargs\): &nbsp;&nbsp;File &quot;/usr/lib/python2\.6/site\-packages/matplotlib/axes\.py&quot;, line 331, in \_plot\_2\_args &nbsp;&nbsp;&nbsp;&nbsp;func\(x, y\) &nbsp;&nbsp;File &quot;/usr/lib/python2\.6/site\-packages/matplotlib/axes\.py&quot;, line 314, in makefill &nbsp;&nbsp;&nbsp;&nbsp;\(x\[:,np\.newaxis\],y\[:,np\.newaxis\]\)\), TypeError: list indices must be integers, not tuple rpm -q python-matplotlib
python-matplotlib-0.98.5.2-1.3