Hello, I am trying to capture the trace name of the scatter.on_click event. While it allows to do that for an individual trace (one at the time) it does not allow me to combine the data from multiple traces (A & B from below example) under same scatter object. Anyone know how to fix it? Appreciate the advice. Many thanks
Below is the code:
import plotly.graph_objects as go
f = go.FigureWidget([go.Scatter(x=[1,2,3], y=[3,5,6], mode=βlinesβ, name=βAβ),
go.Scatter(x=[4,5,6], y=[5,7,9], mode=βlinesβ, name=βBβ)])
scatter = f.data[0] # trace A data
scatter = f.data[1] # trace B data overrides the the first trace A
f.layout.hovermode = βclosestβ
def update_point(trace, points, selector):
for i in points.point_inds:
print(scatter.name)
scatter.on_click(update_point)
f