我有一个使用RGL的3D图.我想用颜色制作相同的图来突出显示某些变量的分布.要做到这一点,我想有相同的情节,我如何找到和设置情节的方向?
一旦我做了一个初步的情节,我移动它找到一个很好的显示角度,我想保存这个角度,并将其纳入未来的绘图脚本.有人建议如何做到这一点?
library(rgl)
plot3d(iris)
#play with the plot to find a good angle
#save the angle for future plots
Run Code Online (Sandbox Code Playgroud) 我有一个闪亮的应用程序,并将一个rgl 3d-plot集成到其中.我正在renderRglwidget从rglwidget包中使用webgl将rgl图形插入到我的闪亮应用程序中.
在应用程序中,用户可以旋转图形.现在我想保存旋转状态,因此userMatrix或modelMatrix稍后生成一个类似的绘图,其旋转与用户离开上一个图形相同.
这里我读了一些关于存储userMatrix和其他参数的java变量.我可以从我的闪亮应用程序(R代码)中访问它们吗?
在rgl本身中,我可以使用rotationMatrix <- rgl.projection()$model或rotationMatrix <- par3d()$modelMatrix 存储模型的旋转.但是因为在我的情况下,图形不会在rgl中旋转,这些功能对我没有帮助.
我试过的是这个:
library(shiny)
library(rgl)
library(rglwidget)
ui <- fluidPage(
rglwidgetOutput("3D-plot"),
actionButton("showMatrix", "show rotation Matrix")
)
server <- function(input, output, session){
open3d(useNULL = T)
x <- sort(rnorm(1000))
y <- rnorm(1000)
z <- rnorm(1000) + atan2(x, y)
plot3d(x, y, z, col = rainbow(1000))
scene1 <- scene3d()
rgl.close()
output$"3D-plot" <- renderRglwidget({
rglwidget(scene1)
})
observe({
input$showMatrix
par3d()$modelMatrix
})
}
shinyApp(ui=ui, server=server)
Run Code Online (Sandbox Code Playgroud)
但par3d()$modelMatrix似乎没有返回任何东西.