Marc Chen
Marc Chen

Reputation: 11

Trying to create an animated radar chart in python plot.ly

I'm trying to create radar charts in plotly exactly like the ones described here Except I would like to animate the chart as it moves between different source data with a button. I've been trying to implement the animation mechanics described here

All of the examples of animations that I can find for plotly are only for cartesian coordinates. My code can initialize the radar chart but can't seem to get the animation to begin.

(run on Jupyter for the visualize to generate!)

Thank you so much in advance for any help!

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)

Upvotes: 1

Views: 909

Answers (1)

Jon Mease
Jon Mease

Reputation: 339

The scatterpolar trace type doesn't currently support animation.

I confirmed this by searching for the animatable property in the plotly.js repository (https://github.com/plotly/plotly.js/search?utf8=%E2%9C%93&q=animatable&type=). At present, only the scatter and carpet trace types support animation.

Feel free to open a feature request issue in the plotly.js repository!

Upvotes: 1

Related Questions