plotly_express icon indicating copy to clipboard operation
plotly_express copied to clipboard

on_click doesn't work

Open Boomer91 opened this issue 6 years ago • 3 comments

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

Boomer91 avatar May 11 '19 00:05 Boomer91

What are Points() and InputDeviceState() here?

nicolaskruchten avatar May 11 '19 00:05 nicolaskruchten

from plotly.callbacks import Points, InputDeviceState

Boomer91 avatar May 11 '19 04:05 Boomer91

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.

nicolaskruchten avatar May 11 '19 12:05 nicolaskruchten