[R] save rgl.sphere plot

Duncan Murdoch murdoch.duncan at gmail.com
Fri Jun 10 16:17:46 CEST 2016


On 10/06/2016 9:14 AM, ch.elahe via R-help wrote:
> Hi all
> I have generated a 3D interactive rgl.sphere but I don't know how to save it to be viewed also interactive(being able to rotate it and do zoom-in and out). Does anyone know how should I save it?
> Thanks for any help!

I'd recommend using knitr and rglwidget.  For example, put this in 
example.Rmd:



---
title: "Example"
author: "Duncan Murdoch"
date: "June 10, 2016"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
options(rgl.useNULL = TRUE)
library(rgl)
library(rglwidget)
xyz <- matrix(rnorm(30), ncol = 3)
spheres3d(xyz, col = 1:10)
rglwidget()
```


and then in RStudio, click on "knit HTML".  If you don't use RStudio, 
you can run

rmarkdown::render("example.Rmd")

and then view the "example.html" file in your browser.

Duncan Murdoch



More information about the R-help mailing list