Plotly: How to change the default mode bar button?

Viewed 1198

I am generating plotly graphics and using shinyapps to publish COVID data from my country.

But when I generate the plot the default modebar button is the "zoom" function and it makes complicated its use on a smartphone:

enter image description here

I need the "Pan" function is the default button but I could find the solution.

enter image description here

Thanks in advance.

1 Answers

Just include:

fig <- fig %>% layout(dragmode='pan')

This will change your default activated menu option from...

enter image description here

... to:

enter image description here

Complete code:

x <- c(1:100)
random_y <- rnorm(100, mean = 0)
data <- data.frame(x, random_y)

fig <- plot_ly(data, x = ~x, y = ~random_y, type = 'scatter', mode = 'lines')

fig <- fig %>% layout(dragmode='pan')
fig

I hope this is what you were looking for! Don't hesitate to let me know if not.

Related