6

I would like to custom the modebar (on top right) so as to keep just "zoom","pan","box select","zoom in" and "zoom out". If it's not possible, I prefer display the modebar.

Here graph and code : enter image description here

x <- c(1:15)
y <- c(1:15)
xy <- as.data.frame(cbind(x,y))
example <- ggplot(data = xy,aes(x = x,y = y))+geom_line()
ggplotly(example)

Thank you for help

Estelle Duval
  • 313
  • 4
  • 12
  • Oh... Because some options doesn't work or are inappropriates so I can't keep it. But if I don't have choices so be it... Thank you – Estelle Duval May 25 '16 at 13:35

2 Answers2

11

Using your example:

x <- c(1:15)
y <- c(1:15)
xy <- as.data.frame(cbind(x,y))
example <- ggplot(data = xy,aes(x = x,y = y))+geom_line()

ggplotly(example) %>% config(displaylogo = FALSE,
modeBarButtonsToRemove = list(
    'sendDataToCloud',
    'toImage',
    'autoScale2d',
    'resetScale2d',
    'hoverClosestCartesian',
    'hoverCompareCartesian'
))

Example output

Other options include: 'zoom2d','pan2d','select2d','lasso2d','zoomIn2d', and 'zoomOut2d'

scogra77
  • 126
  • 2
  • 5
  • any idea why this isn't working anymore? i've updated packages a few times sine your post and now the mode bar buttons are back! – rrs Apr 06 '17 at 21:11
2

Concatenate the buttons to remove, instead of making a list.

The following works for me:

x <- c(1:15)
y <- c(1:15)
xy <- as.data.frame(cbind(x, y))
example <- ggplot(data = xy, aes(x = x, y = y)) + geom_line()

ggplotly(example) %>% config(displaylogo = FALSE,
modeBarButtonsToRemove = c(
    'sendDataToCloud',
    'toImage',
    'autoScale2d',
    'resetScale2d',
    'hoverClosestCartesian',
    'hoverCompareCartesian'
))
Hallie Swan
  • 2,714
  • 1
  • 15
  • 23