Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export an interactive rgl 3D Plot to share or publish?

Tags:

r

3d

pca

rgl

I have made an interactive 3D plot in R using the rgl package. I would like to be able to send it (and keep it interactive) to a colleague so she can present it (rotate it) in a meeting on her laptop. Is there a way to do this?

Here is the code I used to generate the plot:

And this is the plot:

library(rgl)
plot3d(pcaGB$x[,1:3], col=gbMeta2.5K$gbColor, type='s', size=1)

enter image description here

I am then using this code to export it to HTML using writeWebGL, but without any luck so far:

browseURL(paste("file://", writeWebGL(dir=file.path("~/Documents/", "webGL"), width=700), sep=""))

This is what I get back in a browser window:

enter image description here

I've also tried using just writeWebGL but that creates a folder in the directory with an index.html file that opens the same image as above in the browser.

like image 704
gaelgarcia Avatar asked Jun 17 '15 23:06

gaelgarcia


1 Answers

You can export the interactive plot to html using knitr. For the details see: including a interactive 3D figure with knitr.

like image 164
Lars Lau Raket Avatar answered Sep 20 '22 17:09

Lars Lau Raket