Trouble with converting offline animation to online


#1

Hello, I am in the final stage of a project I’ve been working on for some time. I built a choropleth time-series world map animation in offline mode and now I am seeing that doing it online requires a different process. I’ve looked around and it looks like this person tried but had a lot of difficulty and never resolved it: Python plotly: how to make a choropleth map with a slider (access grid data issue)

Does anyone know of a way to do it? Secondly, I would also accept workarounds at this point. Basically, I am trying to put this into a medium(.)com blog post but they do not support embedding raw html. I instead have to use embedly. Is saving the raw html with another provider, say github, and then moving it to medium through embedly an option?

Is there any way to get the offline mode version into my medium post? Or do I have to figure out the plotly online mode grid process? Seems like there might be other options too, Dash, Chart studio, etc, but I really don’t want to go down those rabbitholes without knowing definitively which path is the best.

Thank you so much for reading.


#2

Hi @mattius459,

Unfortunately, the only way to do this at the moment is to extract the data columns into grids columns and use the plotly.plotly.create_animations API. (See https://plot.ly/python/gapminder-example/)

I do want to automate the process of replacing data columns with grid references eventually. I may be able to spend some time on that this weekend. Are you interested in sharing the JSON representation of your figure as something I can test on? Feel free to DM it to me if you don’t want to make it public yet.

-Jon


#3

Thanks for the response @jmmease

I managed to get it working after some toiling. My article is up now and I am really happy with the way it turned out:


#4

Hi @mattius459,

Glad you got something working and thanks for sharing! I did spend some time on this this weekend, and you can see the results in https://github.com/plotly/plotly.py/pull/1432.

With these changers, the create_animations function will support figures with inline data (the kind that work offline) by automatically extracting the data arrays into a grid. It will also support overwriting existing figures and folder structures.

Eventually this implementation will replace plotly.plotly.plot and you won’t have to do anything differently if your figure has animations :slightly_smiling_face:

Once we publish a release candidate of this functionality, would you be willing to try it out on your original example and let us know how it goes?

Thanks,
-Jon