为什么我的Python散点图不能工作? [英] Why won't my Python scatter plot work?

查看:588
本文介绍了为什么我的Python散点图不能工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用pylab创建了一个非常简单的散点图。

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


推荐答案

我打赌engineSize,fuelMile是蜇伤, ,如果是这样的话,你必须将它们转换为float,然后将它们作为参数传递给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

floatval = float(strval)

这篇关于为什么我的Python散点图不能工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆