10

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.

Carmen Sandoval
  • 2,266
  • 5
  • 30
  • 46
  • Thanks, but I need it to still be interactive upon exporting, so that she can rotate it herself. – Carmen Sandoval Jun 17 '15 at 23:54
  • Yes, I tried it but it doesn't seem to be working. And also I don't know how I would share it with her if it did ... ? – Carmen Sandoval Jun 17 '15 at 23:55
  • Thanks for your response. I have added the code I've been trying to use writeWebGL to my question. It just opens a browser window with an error :( – Carmen Sandoval Jun 18 '15 at 00:26
  • try making the figure, then just `writeWebGL()` should create a folder webGL in your working directory with the stuff in it – Rorschach Jun 18 '15 at 00:37
  • Still not working. I tried with just `writeWebGL()`, but that made a folder in the directory with a CanvasMatrix.jl file, an index.html file and a snapshot.png that looks like a close up of one of the edges of the cube. – Carmen Sandoval Jun 21 '15 at 01:40

1 Answers1

3

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

Community
  • 1
  • 1
Lars Lau Raket
  • 1,905
  • 20
  • 35