Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Remove Lasso Select, Box Select & Toggle Spike Lines from Mode Bar

I’ve been trying to find a way to remove Lasso Select, Box Select & Toggle Spike Line options from the Mode Bar.
modebar

I found code in the Github repo related to the modebar buttons but I don’t see any references to the three buttons mentioned above: https://github.com/plotly/plotly.js/blob/v1.3.0/src/components/modebar/buttons.js.

Does anybody know the names to use for these buttons inside the modeBarButtonsToRemove array?

I’ll answer my own question, here’s the full list of Mode Bar button names:

“zoom2d”, “pan2d”, “select2d”, “lasso2d”, “zoomIn2d”, “zoomOut2d”, “autoScale2d”, “resetScale2d”, “hoverClosestCartesian”, “hoverCompareCartesian”, “zoom3d”, “pan3d”, “resetCameraDefault3d”, “resetCameraLastSave3d”, “hoverClosest3d”, “orbitRotation”, “tableRotation”, “zoomInGeo”, “zoomOutGeo”, “resetGeo”, “hoverClosestGeo”, “toImage”, “sendDataToCloud”, “hoverClosestGl2d”, “hoverClosestPie”, “toggleHover”, “resetViews”, “toggleSpikelines”, “resetViewMapbox”

REF: http://www.somesolvedproblems.com/2018/10/how-to-customize-plotlys-modebar.html

I would like to do exactly just that, remove lasso and box select from mode bar. Or lock them. box select activate while going down when browsing on a phone.

However, I did not understand the explaination on the link :frowning: can I modify this while staying in R? Do I edit the plotly object afterwards? Could you explain more in details the procedure?

In R, you can remove buttons using code like the following:

plot_ly() %>%
  config(modeBarButtonsToRemove = c("zoomIn2d", "zoomOut2d"))

See 26 Control the modebar | Interactive web-based data visualization with R, plotly, and shiny for more details on how to control the modebar.