0

Hello I'm trying to display the figure of this code in google colab it's figuring the plot but when I try to click each point it's not working, it should be turning a green circle, I think the problem is on_click function but i couldn't resolute that problem can anyone help me? I think f.show makes my figure static but i need dynamic figure each touch should call my function

        import plotly.graph_objects as go

import numpy as np
np.random.seed(1)

x = np.random.rand(100)
y = np.random.rand(100)

f = go.FigureWidget([go.Scatter(x=x, y=y, mode='markers')])

scatter = f.data[0]
colors = ['#a3a7e4'] * 100
scatter.marker.color = colors
scatter.marker.size = [10] * 100
f.layout.hovermode = 'closest'


# create our callback function
def update_point(trace, points, selector):
    c = list(scatter.marker.color)
    s = list(scatter.marker.size)
    for i in points.point_inds:
        c[i] = '#bae2be'
        s[i] = 20
        with f.batch_update():
            scatter.marker.color = c
            scatter.marker.size = s


scatter.on_click(update_point)

f

f.show() makes figure static but i need interactive figure in here

Kaan
  • 11
  • 2
  • Does this answer your question? [Plotly notebook mode with google colaboratory](https://stackoverflow.com/questions/47230817/plotly-notebook-mode-with-google-colaboratory) – Oliver Hnat Apr 02 '22 at 10:36
  • A developer commented on a similar question in the plotly community, stating that he doesn't think plotly custom widgets are supported. See this:[FigureWidget and GraphWidget not working in colab](https://community.plotly.com/t/figurewidget-and-graphwidget-not-working-in-colab/34321/5) – r-beginners Apr 02 '22 at 13:30

0 Answers0