Plotly notebook mode with google colaboratory

plotly version 4.x

As of version 4, plotly renderers know about Colab, so the following is sufficient to display a figure in both Colab and Jupyter (and other notebooks like Kaggle, Azure, nteract):

import plotly.graph_objects as go
fig = go.Figure( go.Scatter(x=[1,2,3], y=[1,3,2] ) )

plotly version 3.x

Here’s an example showing the use of Plotly in Colab. (Plotly requires custom initialization.)

You need to define this function:

def configure_plotly_browser_state():
  import IPython
        <script src=""></script>
            paths: {
              base: '/static/base',
              plotly: '',

And call it in each offline plotting cell:


Leave a Comment