【问题标题】:How to remove option bar from ggplotly plot?如何从 ggplotly 图中删除选项栏?
【发布时间】:2017-03-06 12:27:59
【问题描述】:

我有一个使用plotlyggplot2shiny 中渲染的情节。但是,我不希望出现悬停时出现的选项栏。有没有办法使用ggplotly(p) 去掉选项栏?

【问题讨论】:

    标签: r ggplot2 shiny plotly shinydashboard


    【解决方案1】:

    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)
    

    【讨论】:

    • 有没有办法更永久地做到这一点?例如,如果我将其另存为网页,则工具栏会返回
    • 我希望每次回来时都能投票赞成这个答案(很多)
    • @BastiaanQuast 你解决了工具栏出现在网页上的问题吗?
    猜你喜欢
    • 2016-04-09
    • 2021-06-06
    • 1970-01-01
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 2011-03-19
    • 1970-01-01
    • 2017-05-03
    相关资源
    最近更新 更多