如何在 plotly 中自定义或显示模式栏?

How to custom or display modebar in plotly?

我想自定义模式栏(在右上角)以便只保留 "zoom"、"pan"、"box select"、"zoom in" 和 "zoom out".如果不可能,我更喜欢显示模式栏。

这里是图表和代码:

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)

感谢您的帮助

使用你的例子:

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

其他选项包括:'zoom2d'、'pan2d'、'select2d'、'lasso2d'、'zoomIn2d' 和 'zoomOut2d'

连接要删除的按钮,而不是制作列表。

以下对我有用:

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'
))