我有一个使用
shiny
和 plotly
在 ggplot2
中渲染的图。但是,我不希望出现悬停时出现的选项栏。有没有办法使用 ggplotly(p)
并删除选项栏?
在社区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 = FALSE)
如果您不使用
ggplotly
,您可以这样做:
plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity),
mode = "markers", color = carat, size = carat) %>% config(displayModeBar = FALSE)