I encounter some problem when using the rgl package to plot a 3D picture on shinyR. My code works without error or problem on the local Rstudio. The 3D plot does really show up just as I expected. However, whenever I publish it to shinyapps.io through rsconnect package, the 3D plot does not show up on the website. Simultaneously, no error occurs. This confuses me a lot. I look for the solution on the internet and upload a simple example to test. Here is the code:
library(shiny)
library(rgl)
library(rglwidget)
options(rgl.useNULL=TRUE)
open3d(useNULL = TRUE)
ids <- plot3d(rnorm(100), rnorm(100), rnorm(100))[1]
scene <- scene3d()
rgl.close()
ui <- (fluidPage(
checkboxInput("chk", label = "Display", value = FALSE),
rglwidgetOutput("wdg")
))
server <- function(input, output, session) {
options(rgl.useNULL = TRUE)
save <- options(rgl.inShiny = TRUE)
on.exit(options(save))
output$wdg <- renderRglwidget({
rglwidget(scene)
})
}
if (interactive())
shinyApp(ui = ui, server = server)
Finally, there is error message:
Warning in rgl.init(initValue, onlyNULL) :
RGL: unable to open X11 display
Warning: 'rgl_init' failed, running with rgl.useNULL = TRUE
The functions in the rglwidget package have been moved to rgl.
Attaching package: 'rglwidget'
The following objects are masked from 'package:rgl':
playwidget, rglwidget
Error in value[3L] : app.R did not return a shiny.appobj object.
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
As you can see, the error message mentions “X11”, I google this only to find all these X11 problems are related to ubanto or mac environment (mine is win10 ). Therefore, I couldn't find useful answer. I have also tried the capabilities() function but the result just says my X11 is False. I could not figure out which part went wrong and hence I list all my information.
Great thanks if anyone can help or provide further information.
You shouldn't use the rglwidget
package; it is obsolete.
The warnings about X11 are coming because you're trying to set up a local window on the Shiny server. To avoid doing that, use options(rgl.useNULL = TRUE)
before library(rgl)
. If you do this, it won't be necessary in the open3d
call.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.