本文介绍了如何在闪亮的页面而不是弹出窗口中渲染scatter3d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在闪亮的App中实现3D交互式绘图的方法,到目前为止,我一直在使用plotly.但是,plotly有一个主要缺点,即渲染时非常慢.我已经进行了检查,尽管涉及到大量数据,但整个更新更新的outplot $ plot<-renderPlotly({.....})和plotlyOutput("plot")的创建仍不到0.5秒.多年来这是一个已知的问题,但似乎仍然是最新的.

I'm looking at implementing 3D interactive plots in my shiny App, and so far I've been using plotly. However, plotly has one major disadvantage, it's extremely slow when rendering.I've done checks, and the whole creation of updated outplot$plot <- renderPlotly ({.....}) and plotlyOutput("plot") takes less than 0.5 seconds, despite the large data set involved. This is a know issue for years but still seems to be current.

因此,我希望使用一个名为car的软件包,这也是因为它具有许多选项,我特别希望其中一些选项在其他软件包中不可用.有关汽车包装的信息,请访问:http://www.sthda.com/english/wiki/amazing-interactive-3d-scatter-plots-r-software-and-data-visualization问题在于它呈现在单独的弹出窗口中,而不是在闪亮的应用程序中呈现,我希望将其包含在其中,甚至更好的是,添加一个按钮,使用户可以将其作为弹出窗口使用,但仅在被询问时才使用.但是,我不知道如何将bugger塞进实际的闪亮页面中.

Hence, I'm looking to use a package called car, also because it has many options, some which I particularly want that are not available in other packages. Info on the car package is here: http://www.sthda.com/english/wiki/amazing-interactive-3d-scatter-plots-r-software-and-data-visualizationThe problem is that it renders in a separate popup window rather than inside the shiny app, and I want to have it inside it, or even better, add a button that allow the user to have it as a popup, but only when asked. However, i can't figure out how to jam the bugger into the actual shiny page.

这是我的最小示例,其中包含单个文本元素,并且图形代码(在我的情况下)始终显示在单独的窗口中,而不是在应用程序中.

Here is my minimal example with a single text element and the graph code that (in my case) keeps appearing in a separate window rather than in the app.

install.packages(c("rgl", "car", "shiny"))

library("rgl")
library("car")
library(shiny)

cars$time <- cars$dist/cars$speed


ui <- fluidPage(
  hr("how do we get the plot inside this app window rather than in a popup?"),

  plotOutput("plot",  width = 800, height = 600)
  )


server <- (function(input, output) {


  output$plot <- renderPlot({
    scatter3d(x=cars$speed, y=cars$dist, z=cars$time, surface=FALSE, ellipsoid = TRUE)
    })
})


shinyApp(ui = ui, server = server)

也有此程序包scatterplot3d,但这不是交互式的http://www.sthda.com/english/wiki/scatterplot3d-3d-graphics-r-software-and-data-visualization

There is also this package, scatterplot3d but that's not interactivehttp://www.sthda.com/english/wiki/scatterplot3d-3d-graphics-r-software-and-data-visualization

有一些RGL软件包,但是它们有相同的问题(单独的窗口),并且不提供我所寻找的选项.

And there are some RGL packages but they have the same issue (seperate window) and don't offer the options I am lookign for.

推荐答案

您需要使用rglwidget来获取最后的rgl图并将其放入htmlwidget中.它曾经在单独的程序包中,但最近已集成到`rgl中.

You need to use an rglwidget which takes the last rgl plot and puts in in an htmlwidget. It used to be in a separate package, but it has recently been integrated into `rgl.

这是执行此操作的代码:

Here is the code to do this:

library(rgl)
library(car)
library(shiny)

cars$time <- cars$dist/cars$speed

ui <- fluidPage(
  hr("how do we get the plot inside this app window rather than in a popup?"),

  rglwidgetOutput("plot",  width = 800, height = 600)
)

server <- (function(input, output) {

  output$plot <- renderRglwidget({
    rgl.open(useNULL=T)
    scatter3d(x=cars$speed, y=cars$dist, z=cars$time, surface=FALSE, ellipsoid = TRUE)
    rglwidget()
  })
})
shinyApp(ui = ui, server = server)

提供此:

这篇关于如何在闪亮的页面而不是弹出窗口中渲染scatter3d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 04:06