【问题标题】:How to fix: TypeError: relplot() got multiple values for argument 'x' when plottling a line plot with seaborn如何修复:TypeError: relplot() 在使用 seaborn 绘制线图时获得了参数“x”的多个值
【发布时间】:2020-06-24 10:22:35
【问题描述】:

我正在尝试使用 seaborn 绘制 line plot

使用:

sns.relplot(Data, x="InvoiceYearMonth", y="price", hue="company")

给我一​​个错误:

TypeError: relplot() got multiple values for argument 'x'

可能出了什么问题?

这是我的数据样本供您参考:

    InvoiceYearMonth  company       price
0     202001          companyA      1509.40
1     202001          companyB      469.00
2     202001          companyC      358.81
3     202002          companyD      870.00
4     202002          companyE      465.58
5     202002          companyF      563.00
6     202003          companyG      1140.00

【问题讨论】:

    标签: python python-3.x dataframe matplotlib seaborn


    【解决方案1】:

    您双重指定x:首先作为位置参数(它将x 设置为Data,然后是命名参数x(将x 设置为"InvoiceYearMonth")。
    试试这个:

    sns.relplot(data=Data, x="InvoiceYearMonth", y="price", hue="company")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-16
      • 2021-10-25
      • 2021-05-19
      • 1970-01-01
      • 2019-04-21
      • 2019-07-05
      • 2019-02-08
      • 1970-01-01
      相关资源
      最近更新 更多