plotly / plotly/plotly.R

ggplotly crashes when AGG is required as graphical engine

未关闭
#2,286 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

I'm developing Shiny apps in a platform, where the graphical engine in RStudio (browser version) needs to be AGG.
When making interactive plots with ggplotly the app crashes when running from RStudio with the following error message:

Listening on http://127.0.0.1:7615
Warning: Error in dev_fun: X11 is not available
  106: dev_fun
  105: gg2list
  104: ggplotly.ggplot
  103: ggplotly
  102: %>%
  101: renderPlotly [/PATH_TO_APP/app.R#77]
  100: func
   97: shinyRenderWidget
   96: func
   83: renderFunc
   82: output$distggPlotly
    1: runApp

The static plots in the app are working fine, but the plotly variant causes the problem (see below).

app.R file

library(shiny)
library(tidyverse)
library(plotly)

ui <- fluidPage(

    titlePanel("Old Faithful Geyser Data"),

    sidebarLayout(
        sidebarPanel(
            sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30)
        ),

        mainPanel(
           plotOutput("distPlot"),
           plotOutput("distggPlot"),
           plotlyOutput("distggPlotly")
        )
    )
)

server <- function(input, output) {
  output$distPlot <- renderPlot({
      x    <- faithful[, 2]
      bins <- seq(min(x), max(x), length.out = input$bins + 1)

      hist(x, breaks = bins, col = 'darkgray', border = 'white',
           xlab = 'Waiting time to next eruption (in mins)',
           main = 'Histogram of waiting times')
  })
    
  output$distggPlot <- renderPlot({
    x    <- faithful[, 2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    
    faithful %>% ggplot(aes(x = waiting)) +
      geom_histogram(breaks = bins, fill = 'darkgray', colour = 'white') + 
      labs(x = 'Waiting time to next eruption (in mins)',
           title = 'Histogram of waiting times')
  })
    
  output$distggPlotly <- renderPlotly({
    x    <- faithful[, 2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    
    gg_hist <- faithful %>% ggplot(aes(x = waiting)) +
      geom_histogram(breaks = bins, fill = 'darkgray', colour = 'white') + 
      labs(x = 'Waiting time to next eruption (in mins)',
           title = 'Histogram of waiting times')
    gg_hist %>% ggplotly()
  })
    
}

shinyApp(ui = ui, server = server)

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用 RStudio 的 AGG 图形引擎和 ggplotly() 调用,从提供的 app.R 示例中重现该故障。跟踪通过 gg2list 报告的 X11 错误,并验证 Shiny 应用可以在不要求 X11 的情况下渲染交互式图表。

由索引模型根据 Issue 内容生成。

评估

技术栈
r
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。