From: Finny K. <kur...@mo...> - 2006-03-01 16:53:48
|
I've finally figured out why I've been having trouble creating histograms= . As it turns out, if you pass to hist() a datatype that is numpy.ndarray instead of a Numeric array, you get the following error. Check this out: >>> import numpy >>> import Numeric >>> from pylab import * >>> y=3DNumeric.array([1,2]) >>> hist(y) # This works no problem >>> x=3Dnumpy.array([1,2]) >>> hist(x) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 1857, in hist ret =3D gca().hist(*args, **kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1676, in hist n,bins =3D matplotlib.mlab.hist(x, bins, normed) File "/usr/lib/python2.4/site-packages/matplotlib/mlab.py", line 621, i= n hist dy =3D (ymax-ymin)/bins TypeError: unsupported operand type(s) for -: 'str' and 'str' I'm not exactly sure why this is true, but I've empirically found this ou= t to be the case. If anyone knows why, I'd sure love to know. Thanks, Finny Kuruvilla |