Why are lasso and boxselect tools not shown?

I find this extremely annoying: I am showing a simple scatterplot with one trace and everything left to the default (which shows it as “lines+markers”).

When the plot has up to 19 datapoints the lasso and boxselection tools are shown

When the plot has 20 or more datapoints, the lasso and boxselection tools disappear!!!

Why on earth would you do that? This is even the case if I then zoom in and less the 20 points are shown in the figure.

I want to use to on_selection callback when showing a selection from a (zoomed) in time-series which has many thousands of datapoints. But since on selection only works with the selection tool and the selection tool is not shown this does not work.

I really do not understand why these tools, especially the boxselection tools are made to disappear.

Is there any way around this limitation? Could it be regarded as a bug (as it seriously limits the usefulness of the tool / the callback for real life situations)?

HI @johann.petrak, I just tried what you describe and you are right. Until 19 points the default behaviour of a go.Scatter seems to be mode='markers+lines'

Then form 20 on it switches to mode='lines'

I don’t know why this is, but you have to specify the mode='markers+lines' manually when plotting n>=20 points

import plotly.graph_objects as go

pn=22
fig = go.Figure(data=go.Scatter(x=[*range(pn)], y=[*range(pn)], mode='lines+markers'))
fig.show()

EDIT: you might be asking yourself, how this answers your question. It seems, that the select buttons are hidden, if mode='lines. With mode='markers+lines' they are available- independent from the number of points plotted

1 Like

Thanks that makes sense, though I do not really understand what the motivation is to hide these tools even when the mode is lines? E.g. with a time series as I described, it would make perfect sense to just show lines as lines+markers clutter up the graph a lot, but still be able to interact and select a subsequence of the series and the corresponding data points.

That design decisions does not make any sense to me, really.

Hi @johann.petrak,

another workaround:

If you have a lot of points and actually don’t want to see them but need the lasso function- set the marker color opacity to 0 via rgba string:

import plotly.graph_objects as go

pn=22
fig = go.Figure(
    data=go.Scatter(
        x=[*range(pn)], 
        y=[*range(pn)], 
        mode='lines+markers',
        line_color='crimson', 
        marker_color='rgba(0,0,0,0)' 
    )
)
fig.show()
1 Like