【问题标题】:Why I get eror when I want to use plt.scatter?为什么我想使用 plt.scatter 时会出错?
【发布时间】:2022-01-21 09:11:40
【问题描述】:

我想在数据库上使用 matplotlib 库中的 scatter 函数,但我根本做不到。

下面是我的代码和错误:

import matplotlib as plt

y = df["price"]

x = df["engine-size"]

plt.scatter(x,y)

错误:AttributeError:模块'matplotlib'没有属性'scatter'

【问题讨论】:

标签: python matplotlib scatter


【解决方案1】:

【讨论】:

    【解决方案2】:

    以这种方式导入;

    从 matplotlib 导入 pyplot 作为 plt

    然后再次运行您的代码 这应该工作

    【讨论】:

    • 哦,我的错。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 2010-10-18
    • 2021-10-02
    • 1970-01-01
    • 2021-05-01
    • 2020-08-26
    • 2021-09-10
    相关资源
    最近更新 更多