【问题标题】:Cannot make plotly config work in R无法使情节配置在 R 中工作
【发布时间】:2018-08-20 13:11:54
【问题描述】:

我想使用 R-shiny 显示一个情节图,但没有模式栏。我正在尝试使用配置选项,但它不起作用。代码如下:

library(shiny)
library(plotly)

ui <- fluidPage(

      plotlyOutput("plot")

)
server <- function(input, output, session) {



  output$plot <- renderPlotly({

    p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
    config(p, displayModeBar = FALSE)

    p
  })

}

shinyApp(ui, server)

此代码正确显示绘图但忽略配置。模式栏仍然出现。我还尝试了不同的配置选项,比如 displaylogo = FALSE、collection = FALSE 分别隐藏 logo 和协作选项,它们也被忽略了。

有人知道它为什么不起作用吗?我的情节版本是 4.8.0

我非常感谢您对此的任何见解。

【问题讨论】:

  • 只需分配p&lt;- config(p, displayModeBar = FALSE)

标签: r shiny plotly r-plotly


【解决方案1】:

另一种解决方案是将您的 p 定义为:

  p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length) %>%
       config(p, displayModeBar = FALSE)

或者只是运行:

plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length) %>%
config(p, displayModeBar = FALSE)

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2013-11-20
  • 1970-01-01
  • 2018-06-23
  • 2016-01-25
  • 1970-01-01
  • 2021-12-03
  • 2019-06-26
  • 1970-01-01
相关资源
最近更新 更多