[英]Why am I receiving an invalid syntax error for this code to make a plot using plotly?
I have two data frames (gyeEUR and gyeEMR) wit incident cases per 100k measured in different countries by year.我有两个数据框(gyeEUR 和 gyeEMR),每年在不同国家/地区测量每 10 万例事件。 I am looking to make 2 side by side scatter plots in plotly with year on the x axis and incident cases per 100k on the y axis and different colored lines for the different countries.我希望在 plotly 中制作 2 个并排散点图,x 轴为年份,y 轴为每 100k 的事件案例,不同国家/地区的不同颜色线。 I am using the following code:我正在使用以下代码:
fig = make_subplots(rows=2, cols=1)
fig.add_trace(
go.Scatter(x=gyeEMR["year"], y=gyeEMR["incident cases per 100k", color=gyeEMR["country"]], row=1, col=1
)
fig.add_trace(
go.Scatter(x=gyeEUR["year"], y=gyeEUR["incident cases per 100k"], color=gyeEUR["country"]),
row=2, col=1
)
fig.update_layout(height=600, width=800)
fig.show()
This code has been returning an invalid syntax error for fig.add_trace and I don't understand why.此代码一直为 fig.add_trace 返回无效的语法错误,我不明白为什么。 Could someone point me towards what I am doing wrong?有人可以指出我做错了什么吗?
Edit: Here is the error编辑:这是错误
Edit: Here is the gyeEMR dataframe编辑:这里是 gyeEMR dataframe
You one missing one paranthesis in the first add_trace
:您在第一个add_trace
中缺少一个括号:
fig.add_trace(
go.Scatter(x=gyeEMR["year"], y=gyeEMR["incident cases per 100k"], color=gyeEMR["country"], row=1, col=1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.