[DELETE] Click Events in Python (example from documentation not working)


I would like to know whether or not it if possible to create an HTML file from a Plotly Express (strip) object that calls a Python script when a dot is clicked.

However, I have found that the basic example from here:

fails with the following error message (within Jupyter Lab):

AttributeError                            Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/IPython/core/formatters.py:921, in IPythonDisplayFormatter.__call__(self, obj)
    919 method = get_real_method(obj, self.print_method)
    920 if method is not None:
--> 921     method()
    922     return True

File ~/.local/lib/python3.10/site-packages/plotly/basewidget.py:741, in BaseFigureWidget._ipython_display_(self)
    737 """
    738 Handle rich display of figures in ipython contexts
    739 """
    740 # Override BaseFigure's display to make sure we display the widget version
--> 741 widgets.DOMWidget._ipython_display_(self)

AttributeError: type object 'DOMWidget' has no attribute '_ipython_display_'

My own code also fails with the exact same message:

import pandas as pd
import plotly.express as px
import plotly.graph_objects as go

df = pd.read_csv('Shap_FI.csv')

#values = df.iloc[:,2:].columns
values = df.iloc[:,2:].abs().mean(axis=0).sort_values().index
df_plot = pd.melt(df, id_vars=['transaction_id', 'predictions'], value_vars=values, var_name='Feature', value_name='SHAP')

fig = px.strip(df_plot, x='SHAP', y='Feature', color='predictions', stripmode='overlay', height=4000, width=1000, hover_data=['transaction_id'])
fig.update_layout(xaxis=dict(showgrid=True, gridcolor='WhiteSmoke', zerolinecolor='Gainsboro'),
              yaxis=dict(showgrid=True, gridcolor='WhiteSmoke', zerolinecolor='Gainsboro')


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

f = go.FigureWidget(fig)
scatter = f.data[0]



If I get it to work, would it be possible to save it as HTML (without a Jupyter Notebook)? Obviously, the click function would be different.