FigureWidget and GraphWidget not working in colab

My goal is to use a widget connected to a line chart that allows the user to view pieces of timeseries data by date. I assume using FigureWidget would be the best way. However…

The following does not work in colab:

import plotly.graph_objects as go

f = go.FigureWidget()
f
  • should I be using FigureWidgets for this scenario?

  • if so, how do i get them to work in colab?

Note: I’ve also tried this example. The widgets show up. The plot does not. This makes assume GraphWidget is not working.

thank you.

I’m experiencing the same problem. Is there any workaround?

I am getting the same problem.

It works in a Jupyter notebook but not in a Colab notebook. Why is that?

Was a solution found?

import plotly.graph_objects as go

f = go.FigureWidget()
f.show()

works for me (shows the graph)

import plotly.graph_objects as go

f = go.FigureWidget()
f.show()

This shows the figureWidget object as a static figure and not a dynamic widget-type plot, and so this doesn’t work as intended. My particular goal is to click on a point on a plotly mesh3D plot, which will then trigger some activity in other ipywidgets. For example, the following code will simply show the Cartesian coordinates of a clicked plotly point in some ipywidget text boxes:

import plotly.graph_objects as go
from plotly.callbacks import Points, InputDeviceState
from ipywidgets import widgets
points, state = Points(), InputDeviceState()

#Function to update widgets on plotly click
def pointPrint(trace, points, state):
    global coordinates, xDisp, yDisp, zDisp
    ind=points.point_inds
    xDisp.value=coordinates[ind,0]
    yDisp.value=coordinates[ind,1]
    zDisp.value=coordinates[ind,2]

#define the trace
trace=go.Mesh3d(x=coordinates[:,0],y=coordinates[:,1],z=coordinates[:,2],
                i=triangulation[:,0],j=triangulation[:,1],k=triangulation[:,2])

#Setup to ipywidgets
xDisp=widgets.FloatText(
value=0,
description='x',
disabled=True)

yDisp=widgets.FloatText(
value=0,
description='y',
disabled=True)

zDisp=widgets.FloatText(
value=0,
description='z',
disabled=True)

#show everything
fig=go.Figure(data=[trace])
f2=go.FigureWidget(fig)
scatter=f2.data[0]
scatter.on_click(pointPrint)
widgets.VBox([xDisp,yDisp,zDisp,f2])

This works seamlessly in a Jupyter notebook. In colab, simply nothing happens… there are no errors or messages, simply nothing is displayed. If the ‘f2’ in the last line of code above is removed and the code is run again, then the ipywidgets show as intended with the specified initial value of zero.

As far as I know, Colab doesn’t support custom widgets like ours at all.