Preventing x-axis interaction but keeping box selection

There are two ways of manipulating axis range in plotly with standard options:

  • make a box selection to select a part of the graph
  • drag and drop on the axis to zoom and pan

I want to disabled the second option but keep the first. To be clear:

I want to keep this functionality:

But I want to disable this:

How to do this?

I only know how to disable both (setting fixedrange=True for the given axis).

Here is the code for the figure shown above:

import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 3, 1]))

The lack of answers suggests that there is no (obvious) way to do this in the python backend.

Can anyone with knowledge in plotly.js give me a hint on how to disable this behaviour? I mean, removing a behaviour that exists should always be possible somehow, right?

I think you’re looking for fig.update_layout(dragmode='select')