Trouble with converting offline animation to online

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.

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

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:

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

I’ll be happy to give it a try. Plotly has been very helpful for me but some of the edges definitely need smoothing. Happy to do my part where possible.

Thanks @mattius459,

I recently added an automatic dev build to our Continuous Integration process. Here’s how to install the latest version (as of this post). I’d recommend doing this in a new virtual environment or conda environment.

pip install https://10473-14579099-gh.circle-artifacts.com/0/dist/plotly-3.6.1%2B3.g48f2ce4a.tar.gz

After installing this, try uploading your original offline animation (the one not using a Grid that displays in the notebook using plotly.offline.iplot) using plotly.plotly.create_animations. This should automatically extract and upload a grid and then upload the figure with references to the grid. In version 4 the plan is remove any distinction between figures with and without animations when uploading them to Chart Studio.

Plotly has been very helpful for me but some of the edges definitely need smoothing. Happy to do my part where possible.

I appreciate the attitude, this is what I got involved in the first place as well :slightly_smiling_face:

Thanks!
-Jon

Hi Matt, i read your article and it is great. Can you please share the code of how to do this? Thank you! I am struggling on this issue.