A better way to get plotly working on JupyterLab?

I found in this video a way to enable plotly outputs on JupyterLab on every venv.
You have just to call once this function in the notebook:

def configure_plotly_browser_state():
            <script src="/static/components/requirejs/require.js"></script>
                    paths: {
                        base: '/static/base',
                        plotly: 'https://cdn.plot.ly/plotly-1.5.1.min.js?noext',

I have no knowledge of js and HTML, so I ignore what this script is doing. But this method looks simpler than the official solution proposed here in the plotly python API.

Furthermore, with this method, you don’t make permanent changes in your venv. It is also the only way (as far as I know) to get plotly working on a proprietary environment like GCP AI-platform notebooks.

Am I missing something?

The method proposed on the plotly.py github page allows you to create plotly FigureWidgets which adds a lot of features that you won’t get just by injecting the plot into jupyterlab (e.g Python callbacks, in-place figure updates, binary array serialization, and integration with the broader ipywidgets ecosystem). You can see @jmmease’s relevant talk at scipy here.

One other thing that I want to point out here is that the above script will inject an older version of python than plotly.py currently uses so it won’t render new chart types.

plotly: 'https://cdn.plot.ly/plotly-1.5.1.min.js?noext' should probably be updated to plotly: 'https://cdn.plot.ly/plotly-1.49.4.min.js?noext' which is what plotly.py version 4.1.1 uses.

Thank you very much, Micheal. Do you if it would be possible to run correctly plotly figure widgets on GCP AI-platform Jupyterlab notebooks? The method proposed on plotly.py github page works on a Jupyterlab notebook runned on a VM, but not on an AI-platform notebook (plotly shows just a white cell).