Why won't my Python scatter plot work?


I created a very simple scatter plot using pylab.

pylab.scatter(engineSize, fuelMile)

The rest of the program isn't worth posting, because it's that line that's giving me the problem. When I change "scatter" to "plot" it graphs the data, but each point is part of a line and that makes the whole things a scribbly mess. I just want points, not a line, but I get this huge error message that ends with:

  File "C:\Python26\lib\site-packages\numpy\core\fromnumeric.py", line 1643, in amin
    return amin(axis, out)
TypeError: cannot perform reduce with flexible type
11/17/2009 3:09:19 AM

I bet engineSize, fuelMile are stings, try printing them, if that is the case, you have to convert them to float before passing them as arguments to scatter

floatval = float(strval)
3/2/2010 11:31:58 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow