plotly_express
plotly_express copied to clipboard
on_click doesn't work
Trying to add on_click callback function to scatterplot but it does not seem to work unless I'm missing something.
Using Jupter Notebook
import plotly_express as px
f = px.scatter(results, x='column1', y='column2', color='column3', hover_name='ID')
points, state = Points(), InputDeviceState()
def test(trace, points, state):
print('test')
f.data[0].on_click(test)
f
What are Points() and InputDeviceState() here?
from plotly.callbacks import Points, InputDeviceState
Ah ok! Plotly express doesn’t return FigureWidgets but rather Figures so you’ll need to wrap the output in a FigureWidget before this kind of thing will work I believe.