为什么我的 Python 散点图不起作用?
我使用 pylab 创建了一个非常简单的散点图。
pylab.scatter(engineSize, fuelMile)
pylab.show()
该程序的其余部分不值得发布,因为正是该行给我带来了问题。当我将“散点”更改为“绘图”时,它会绘制数据图表,但每个点都是一条线的一部分,这使得整个事情变得一团糟。我只想要点,而不是线,但我收到一条巨大的错误消息,其结尾为:
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
I created a very simple scatter plot using pylab.
pylab.scatter(engineSize, fuelMile)
pylab.show()
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我敢打赌,engineSize,fuelMile 是刺痛,尝试打印它们,如果是这种情况,您必须将它们转换为浮点数,然后再将它们作为参数传递给 scatter
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
好的,既然这有效,那么您的输入一定有问题。显然你需要发布更多内容,除非这个“答案”解决了你的问题:
Okay, so since this works, something must be wrong with your inputs. Clearly you need to post more, unless this "answer" solves your problem: