Pandas: plot() 没有图例但出现 TypeError

Pandas: plot() without legend but getting TypeError

我在设置 legend=False 时收到 TypeError,但根据文档,这应该不是问题。我做错了什么?

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.plot.html

import pandas as pd
pd.options.plotting.backend = "plotly"

row = df.iloc[0]
row.plot(kind='bar', legend=False)

TypeError: bar() got an unexpected keyword argument 'legend'

df.iloc[0] 中的数据如下所示

RevolvingUtilizationOfUnsecuredLines    0.223647
age                                     0.071428
NumberOfTime30-59DaysPastDueNotWorse    1.130581
DebtRatio                               0.361630
MonthlyIncome                          -0.277019
NumberOfOpenCreditLinesAndLoans         0.025073
NumberOfTimes90DaysLate                -0.342467
NumberRealEstateLoansOrLines            0.728451
NumberOfTime60-89DaysPastDueNotWorse   -0.196677
NumberOfDependents                     -0.061967
MonthlyIncomePerPerson                 -0.029531
isRetired                               0.016656
Q1_Monthly_Income_True                  0.032911
Q3_Monthly_Income_True                 -0.000393
Q1_Revolving_True                       0.023684
Q3_Revolving_True                       0.273972

您正在生成 plotly 图。因此更改 return

的布局
pd.options.plotting.backend = "plotly"
df.iloc[1].plot(kind="bar").update_layout(showlegend=False)