How to remove option bar from ggplotly plot?

后端 未结 1 1350
猫巷女王i
猫巷女王i 2021-02-01 22:13

I have a plot that I am rendering in shiny using plotly and ggplot2. However, I do not want the option bar that appears on hover to appear

1条回答
  •  醉话见心
    2021-02-01 22:46

    There is a great answer on community plotly the short version:

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

    Using ggplotly:

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

    If you are not using ggplotly you can do:

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

    0 讨论(0)
提交回复
热议问题