繁体   English   中英

使用 Plotly Express (Python) 的动画多系列折线图

[英]Animated multiseries Line Graph using Plotly Express (Python)

我正在尝试使用 plotly 为多系列折线图制作动画。 然而,经过几天的阅读文档,我似乎仍然找不到解决方案。

目前我的代码如下:

df = px.data.gapminder().query("continent=='Oceania' ")
fig = px.line(df, x="year" , y="lifeExp", color="country" , animation_frame="year", animation_group="lifeExp" , range_y=[68,84] , range_x=[1950,2010])

plot(fig)

然而,这会生成空图。 请帮忙。

我能够使用类似的代码成功生成散点图和条形图。

为了更好地理解,请查看以下链接:我找到了我正在寻找的在 R 中实现的确切示例。

https://plot.ly/r/cumulative-animations/#cumulative-lines-animation

对于空图,尝试通过在代码上方添加以下内容来更改默认渲染器

import plotly.io as pio
pio.renderers.default = 'notebook'

有一些关于不同renderers文档。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM