尝试在Python中创建动画雷达图plot.ly

问题描述 投票:0回答:2

我正在尝试创建与此处描述的完全一样的雷达图 除了我想用按钮在图表在不同源数据之间移动时对图表进行动画处理。我一直在尝试实现here

描述的动画机制

我能找到的所有动画示例仅适用于笛卡尔坐标。我的代码可以初始化雷达图,但似乎无法开始动画。

(在 Jupyter 上运行以生成可视化!)

提前非常感谢您的帮助!

from plotly.offline import init_notebook_mode, iplot
from IPython.display import display, HTML

init_notebook_mode(connected=True)

figure = {'data': [{'fill': 'toself',
          'r': [10, 7, 4, 3, 1, 10],
          'theta': ['A','B','C', 'D','E','A'],
          'type': 'scatterpolar',
          'mode': 'markers'}],

      'layout': {'title': 'radar Animation',
           'polar': {'radialaxis': {'range': [0, 10], 'visible': True}},
           'showlegend': False,
           'title': 'Start Title',
                 'updatemenus': [{'type': 'buttons',
                                  'buttons': [{'label': 'Play',
                                               'method': 'animate',
                                               'args': [None]}]}]},

      'frames': [{
        'data': [{'fill': 'toself',
                  'r': [2, 5, 10, 5, 2, 2],
                  'theta': ['A','B','C', 'D','E','A'],
                  'type': 'scatterpolar',
                  'mode': 'markers'}],

        'data': [{'fill': 'toself',
                  'r': [10, 7, 4, 3, 1, 10],
                  'theta': ['A','B','C', 'D','E','A'],
                  'type': 'scatterpolar',
                  'mode': 'markers'}],

        'layout': {'title': 'End Title'}

    },
                  ]}

 iplot(figure)
python animation plotly radar-chart
2个回答
1
投票

scatterpolar
轨迹类型当前不支持动画。

我通过在plotly.js存储库中搜索

animatable
属性来确认这一点(https://github.com/plotly/plotly.js/search?utf8=%E2%9C%93&q=animatable&type=)。目前,只有
scatter
carpet
迹线类型支持动画。

欢迎在plotly.js 存储库中提出功能请求问题!


0
投票

看看这个家伙的动画。他使用了 matplotlib。 (https://www.marc-julian.de/posts/2022/2/How%20to%20animate%20a%20Radar%20Plot.html

© www.soinside.com 2019 - 2024. All rights reserved.