Good point about the notebook compatibility on colab, it won’t work with notebook_connected (I guess that’s why they have a colab specific renderer!). Maybe a slightly simpler code would leverage the detection already made by plotly. pio.renderers.default
will be ‘colab’ when run there. So the test could be:
import plotly.io as pio
if pio.renderers.default != 'colab':
pio.renderers.default = 'notebook_connected'
# js, etc.