【问题标题】:animation frame lineplot plotly doesn't work (python)动画帧线图情节不起作用(python)
【发布时间】:2020-10-29 11:16:27
【问题描述】:

我正在尝试用 python 和 plotly 创建一个动画折线图。我的数据是从 1750 年到 2018 年在 x 轴和 y 轴上的数据,我的世界二氧化碳排放量以十亿吨为单位(从 0 到 35)。我的 animation_frame 是在“年”,所以我们可以看到演变。

下面是我的代码:

fig = px.line(df_emissions_co2_world, x = "year", y = "co2_billions_t",
          animation_frame = "year", 
          title = " CO2 billions t")

当我显示图表时,我没有看到任何年份出现任何曲线。但是,当我制作没有动画的简单情节线时,我会使用此代码获得所需的数据:

fig = px.line(df_emissions_co2_world, x = "year", y = "co2_billions_t",
          title = " CO2 billions t")

有人会知道问题出在哪里?

【问题讨论】:

  • 请分享您的数据样本

标签: python animation plot plotly line-plot


【解决方案1】:

对我来说,通过将渲染器从 notebook-connected 更改为 notebook 来修复动画无法正常工作但 Plotly 中的所有其他工作。

这里是关于rederers的信息:https://plotly.com/python/renderers/

这是为我修复它的代码:

# These lines before the animated plotly figure
import plotly.io as pio
pio.renderers.default = 'notebook'

【讨论】:

  • 非常适合我 :)
猜你喜欢
  • 1970-01-01
  • 2019-04-11
  • 2013-01-14
  • 2014-09-20
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多