plotly tips and tricks - GitDro/tech-tips GitHub Wiki

Rendering animated plots in vscode

If using plotly.express, the default renderer can be changed:

pio.renderers.default = 'notebook_connected'

This will change the renderer to a version that uses the Plotly JS code directly and in online mode.

If using plotly.graph_objects you can change the default renderer as above or call out the renderer explicitly during fig.show() calls:

fig.show(renderer='notebook_connected')

Source


Using fig.show("notebook") and fig.show("notebook_connected") do result in animations working for me.

Note: fig.show("notebook") also needed for plot to show up in exported HTML files.

Source


Writing images

fig.write_image("images/fig1.png")