如何从 ggplotly 图中删除选项栏?

How to remove option bar from ggplotly plot?

我有一个要使用 plotlyggplot2shiny 中渲染的图。但是,我不希望出现悬停时出现的选项栏。有没有办法使用 ggplotly(p) 并删除选项栏?

community plotly 简短版有一个很好的答案:

library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]

使用ggplotly

p <- ggplot(d, aes(carat, price)) + geom_point()
ggplotly(p) %>% config(displayModeBar = F)

如果您不使用 ggplotly,您可以这样做:

plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity),
mode = "markers", color = carat, size = carat) %>% config(displayModeBar = F)