【问题标题】:No plot displayed with plotly in shiny没有在闪亮的情节中显示情节
【发布时间】:2017-11-07 14:53:02
【问题描述】:

当我将 https://plot.ly/r/shinyapp-plotly-events/ 中的代码粘贴到我的控制台时,没有显示任何 plotly 图形,我无法用 plotly 显示任何闪亮的图形。

我的会话信息:

R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252    LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                    LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] plotly_4.7.0       ggplot2_2.2.1.9000 feather_0.3.1      RODBC_1.3-15       dplyr_0.5.0        shiny_1.0.3

我是否使用了错误的软件包版本?我从 cran 重新安装了所有东西,但我从来没有看到有光泽的情节图。 我可以在查看器中的 RStudio 中生成绘图图。我是否必须使用任何 devtools 版本的 plotly/ggplot/shiny 或所有 devtool 版本?我尝试了 plotly_4.7.0.9000 但仍然没有显示输出。

我发现一个帖子 plotly graph doesn't show up 说 renderPlotly({return(plot_ly(x))}) 已损坏,但即使使用 renderPlotly(data) 我也无法生成任何闪亮的帧。

来自 plotly 库的示例代码,我认为错误应该在我的设置中,作为代码的形式:

library(plotly)
library(shiny)

ui <- fluidPage(
  radioButtons("plotType", "Plot Type:", choices = c("ggplotly", "plotly")),
  plotlyOutput("plot"),
  verbatimTextOutput("hover"),
  verbatimTextOutput("click"),
  verbatimTextOutput("brush"),
  verbatimTextOutput("zoom")
)

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

  output$plot <- renderPlotly({
    # use the key aesthetic/argument to help uniquely identify selected observations
    key <- row.names(mtcars)
    if (identical(input$plotType, "ggplotly")) {
      p <- ggplot(mtcars, aes(x = mpg, y = wt, colour = factor(vs), key = key)) + 
        geom_point()
      ggplotly(p) %>% layout(dragmode = "select")
    } else {
      plot_ly(mtcars, x = ~mpg, y = ~wt, key = ~key) %>%
        layout(dragmode = "select")
    }
  })

  output$hover <- renderPrint({
    d <- event_data("plotly_hover")
    if (is.null(d)) "Hover events appear here (unhover to clear)" else d
  })

  output$click <- renderPrint({
    d <- event_data("plotly_click")
    if (is.null(d)) "Click events appear here (double-click to clear)" else d
  })

  output$brush <- renderPrint({
    d <- event_data("plotly_selected")
    if (is.null(d)) "Click and drag events (i.e., select/lasso) appear here (double-click to clear)" else d
  })

  output$zoom <- renderPrint({
    d <- event_data("plotly_relayout")
    if (is.null(d)) "Relayout (i.e., zoom) events appear here" else d
  })

}

shinyApp(ui, server)

非常欢迎任何建议,谢谢!

【问题讨论】:

  • 它是否可以在不使用闪亮的情况下工作,即 r 控制台中的plot_ly(mtcars, x = ~mpg, y = ~wt, key = ~key)?如果是,您是否尝试设置断点?

标签: r shiny plotly


【解决方案1】:

https://github.com/ropensci/plotly/issues/1042 在 plotly 的 devtools 版本中修复了问题。

devtools::install_github('ropensci/plotly')

【讨论】:

    猜你喜欢
    • 2017-01-21
    • 1970-01-01
    • 1970-01-01
    • 2019-06-19
    • 1970-01-01
    • 1970-01-01
    • 2021-05-10
    • 2017-08-12
    • 1970-01-01
    相关资源
    最近更新 更多