如何将 3D 绘图(rgl)嵌入到通过 knit 创建的 html 中?
\n有几个较旧的帖子正在寻找类似的结果。但是,当我运行我发现的所有示例代码时。rgl-plot don\xc2\xb4t 嵌入到用knitr创建的html中,但在“knitting”时出现在外部窗口中,并在html页面出现时消失。
\n我\xc2\xb4m 寻找的是一种将 3D 绘图集成到生成的 html 中的方法。我不介意它是保持交互还是变成静态。
\n以下示例取自 R Markdown Cookbook: https://bookdown.org/yihui/rmarkdown-cookbook/rgl-3d.html
\ntitle: Embed 3D plots with rgl\noutput: html_document\n---\n\nSet up a hook to save **rgl** plots:\n\n```{r, setup}\nlibrary(rgl)\nknitr::knit_hooks$set(webgl = hook_webgl)\n```\n\nSee if it works for this 3D plot after we enable the hook\nvia the chunk option `webgl = TRUE`:\n\n```{r, test-rgl, webgl=TRUE}\nx <- sort(rnorm(1000))\ny <- rnorm(1000)\nz <- rnorm(1000) + atan2(x,y)\nplot3d(x, y, z, col = rainbow(1000))\n```\nRun Code Online (Sandbox Code Playgroud)\n