R Shiny HTMLWidget for interactive 3D-histograms

后端 未结 3 1680
逝去的感伤
逝去的感伤 2021-01-27 07:11

I would like to include a 3D dynamic (i.e. one can change its perspective just by moving the plot) histogram widget in a R Shiny application.

Unfortunately I di

3条回答
  •  清歌不尽
    2021-01-27 07:37

    It's possible with plot3Drgl. Here is an example.

    library(plot3Drgl)
    library(shiny)
    
    options(rgl.useNULL = TRUE)
    
    ui <- fluidPage(
      rglwidgetOutput("myWebGL")
    )
    
    server <- function(input, output) {
      save <- options(rgl.inShiny = TRUE)
      on.exit(options(save))
      output$myWebGL <- renderRglwidget({
        try(rgl.close())
        V <- volcano[seq(1, nrow(volcano), by = 5), 
                     seq(1, ncol(volcano), by = 5)]  # lower resolution
        hist3Drgl(z = V, col = "grey", border = "black", lighting = TRUE)
        rglwidget()
      })  
    }
    
    shinyApp(ui, server)
    

提交回复
热议问题