Skip to content

on_selection callback seems to not get fired #3910

@Ben-Epstein

Description

@Ben-Epstein

Thanks for your interest in Plotly.py!

Before opening an issue, please search for existing and closed issues :)

Please accompany bug reports with a reproducible example. Please use the latest version of plotly.py in your report unless not applicable.

Note that GitHub Issues are meant to be used for bug reports and feature requests only. Implementation or usage questions should be asked on community.plotly.com or on Stack Overflow (tagged plotly).

It seems the on_selection callback does not fire anymore. I've seen a number of open and closed issues back from 2020 discussing the usage of it, but based on the newest version 5.10.0 I cannot get anything to fire on a selection.

The simplest code example I could find (from #2698)


import plotly.graph_objects as go
import numpy as np

np.random.seed(1)
x = np.random.randn(500)

def on_selection_print(obj, points, selector):
    print(points.point_inds)

figure_widget = go.FigureWidget(data=[go.Histogram(x=x)])
figure_widget.update_layout(dragmode="select")    
figure_widget.data[0].on_selection(on_selection_print)
figure_widget.show()

Both running this in jupyter or as a python script, nothing seems to print.

I tried the latest docs on selection events but I couldn't actually get that example to run in jupyter or otherwise.

Am I just missing something simple?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions