Search code examples
rplotlyr-plotly

Removing buttons from plotly modebar


I'm trying to remove the orbit rotation button in the plotly modebar from a scatter3D plot. According to the manual (26.3 Remove modebar buttons by name) it sounds feasible. However when I try it out the plot vanishes. Regular scatter3d plot:

fig <- plot_ly(mtcars, x = ~wt, y = ~hp, z = ~qsec, color = ~am, colors = c('#BF382A', '#0C4B8E'))
fig <- fig %>% add_markers()
fig

But when I try to remove the button using the list of names here the plot vanishes (and so does the modebar) :

fig %>%
  config(modeBarButtonsToRemove = c("orbitRotation"))

It seems to work for some buttons but not others - is this a bug?


Solution

  • This fails if only a single button is to be removed. See this github issue. If you put the button name into a list it should work:

    fig %>%
      config(modeBarButtonsToRemove = list("orbitRotation"))