TypeError: scatter() got an unexpected keyword argument 'trendline_options' (Plotly, Python)
TypeError: scatter() got an unexpected keyword argument 'trendline_options' (Plotly, Python)
我遇到错误:
TypeError: scatter() got an unexpected keyword argument 'trendline_options'
尝试使用 plotly express 调整最低趋势线的平滑度时。
这是我的图形代码:
fig = px.scatter(dfg, x="Yr_Mnth", y="Episode_Count", color = "Target",
labels={"Episode_Count": tally + " per Shift",
"Target":"Target",
"Yr_Mnth": "Date" },
trendline='lowess',trendline_options= dict(frac=0.1), title="Aggregate Behavior Data: " + patient + " - " + today)
fig.update_xaxes(tickangle=45,)
fig.update_layout(template = 'plotly_white',hovermode="x unified")
数据集(dfg):
Yr_Mnth Target Episode_Count
2020-08-01 Aggression 0.09
2020-08-01 Elopement 0.00
2020-08-01 Self-injury 0.97
2020-09-01 Aggression 0.65
2020-09-01 Elopement 0.00
2020-09-01 Self-injury 1.58
2020-10-01 Aggression 0.24
2020-10-01 Elopement 0.00
2020-10-01 Self-injury 0.75
2020-11-01 Aggression 0.03
2020-11-01 Elopement 0.01
2020-11-01 Self-injury 0.89
2020-12-01 Aggression 0.14
2020-12-01 Elopement 0.00
2020-12-01 Self-injury 0.94
2021-01-01 Aggression 0.05
2021-01-01 Elopement 0.00
2021-01-01 Self-injury 0.30
2021-02-01 Self-injury 0.42
2021-02-01 Elopement 0.03
2021-02-01 Aggression 0.16
2021-03-01 Elopement 0.00
2021-03-01 Self-injury 0.68
2021-03-01 Aggression 0.20
2021-04-01 Aggression 0.10
2021-04-01 Elopement 0.03
2021-04-01 Self-injury 0.33
2021-05-01 Elopement 0.20
2021-05-01 Aggression 0.21
2021-05-01 Self-injury 1.63
2021-06-01 Self-injury 0.90
2021-06-01 Aggression 0.29
2021-06-01 Elopement 0.14
我觉得这很奇怪,因为我直接按照文档操作 - https://plotly.com/python/linear-fits/
这是一个已知问题吗?我无法通过 google 搜索找到任何示例...
正如 Henry 所指出的,这只是一个版本问题,可以通过使用以下内容进行更新来轻松解决:
pip install plotly==5.2.1
我遇到错误:
TypeError: scatter() got an unexpected keyword argument 'trendline_options'
尝试使用 plotly express 调整最低趋势线的平滑度时。
这是我的图形代码:
fig = px.scatter(dfg, x="Yr_Mnth", y="Episode_Count", color = "Target",
labels={"Episode_Count": tally + " per Shift",
"Target":"Target",
"Yr_Mnth": "Date" },
trendline='lowess',trendline_options= dict(frac=0.1), title="Aggregate Behavior Data: " + patient + " - " + today)
fig.update_xaxes(tickangle=45,)
fig.update_layout(template = 'plotly_white',hovermode="x unified")
数据集(dfg):
Yr_Mnth Target Episode_Count
2020-08-01 Aggression 0.09
2020-08-01 Elopement 0.00
2020-08-01 Self-injury 0.97
2020-09-01 Aggression 0.65
2020-09-01 Elopement 0.00
2020-09-01 Self-injury 1.58
2020-10-01 Aggression 0.24
2020-10-01 Elopement 0.00
2020-10-01 Self-injury 0.75
2020-11-01 Aggression 0.03
2020-11-01 Elopement 0.01
2020-11-01 Self-injury 0.89
2020-12-01 Aggression 0.14
2020-12-01 Elopement 0.00
2020-12-01 Self-injury 0.94
2021-01-01 Aggression 0.05
2021-01-01 Elopement 0.00
2021-01-01 Self-injury 0.30
2021-02-01 Self-injury 0.42
2021-02-01 Elopement 0.03
2021-02-01 Aggression 0.16
2021-03-01 Elopement 0.00
2021-03-01 Self-injury 0.68
2021-03-01 Aggression 0.20
2021-04-01 Aggression 0.10
2021-04-01 Elopement 0.03
2021-04-01 Self-injury 0.33
2021-05-01 Elopement 0.20
2021-05-01 Aggression 0.21
2021-05-01 Self-injury 1.63
2021-06-01 Self-injury 0.90
2021-06-01 Aggression 0.29
2021-06-01 Elopement 0.14
我觉得这很奇怪,因为我直接按照文档操作 - https://plotly.com/python/linear-fits/
这是一个已知问题吗?我无法通过 google 搜索找到任何示例...
正如 Henry 所指出的,这只是一个版本问题,可以通过使用以下内容进行更新来轻松解决:
pip install plotly==5.2.1