如何修复:TypeError: relplot() 在使用 seaborn 绘制线图时获得了参数 'x' 的多个值

JA-*_*sta 0 python matplotlib dataframe python-3.x seaborn

我正在尝试与seaborn 一起绘制line plot

使用:

sns.relplot(Data, x="InvoiceYearMonth", y="price", hue="company")
Run Code Online (Sandbox Code Playgroud)

给我一个错误:

TypeError: relplot() got multiple values for argument 'x'
Run Code Online (Sandbox Code Playgroud)

可能出什么问题了?

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

    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
Run Code Online (Sandbox Code Playgroud)

Ste*_*tef 6

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

sns.relplot(data=Data, x="InvoiceYearMonth", y="price", hue="company")
Run Code Online (Sandbox Code Playgroud)