13

The rgl R package allows to plot interactive 3D figures and to save these figures in a html document (with the writeWebGL() function).

I would like to put such an interactive 3D figure in a PowerPoint presentation. Is it possible ?

EDIT: After studying Dieter Menne's answer with the help of Google, my conclusions are the following ones:

  • Currently Luke Tierney's method to convert a 3D graphic to an U3D file and/or an Asymptote file only works for graphics created with the misc3d package, not the rgl package.
  • The export of 3D rgl graphics to VRML/X3D files has been announced as a future plan. Perhaps this would allow to embed a 3D rgl graphic into a Powerpoint and/or LaTeX presentation.

EDIT : related discussion

Community
  • 1
  • 1
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
  • 1
    Have a browser, or even R, running in the background and use Alt-Tab to switch between – James Oct 08 '12 at 12:15

2 Answers2

6

It is possible if you transfer the Powerpoint presentation (or, even more R-ish, use beamer/latex), and embed the 3D-plot as described in Luke Tierney's article

http://homepage.stat.uiowa.edu/~luke/R/misc3d/misc3d-pdf/misc3d-pdf.pdf

Dieter Menne
  • 10,076
  • 44
  • 67
  • Thank you. Of course I prefer the LaTeX rendering but I really need to do the presentation with PowerPoint. What do you mean by "transferring the Powerpoint presentation" ? – Stéphane Laurent Oct 08 '12 at 13:03
  • Export the PP presentation as pdf. – Dieter Menne Oct 08 '12 at 13:25
  • I have created an OFF file with the R package misc3d. But now 1) how to put this file in the Powerpoint presentation ? 2) how to export as pdf ? – Stéphane Laurent Oct 08 '12 at 14:34
  • I don't know Powerpoint, but some googling (feel free to do that!) revealed that the u3d format that misc3d generates can be read directly by Powerpoint, so that the pdf detour is not required (googling for "export pdf powerpoint" gives some thousands hits). – Dieter Menne Oct 08 '12 at 15:42
  • Thanks. I have not find how to read an u3d file in Powerpoint. I hope someone else will help. And then I need Meshlab to convert OFF into u3d ? About the pdf export, I have googled but only find a way with PDFcreator or VirtualPDF – Stéphane Laurent Oct 08 '12 at 15:52
5

If you put this in to an HTML document, you can probably use the IWebBrowser2 object to open the HTML inside a Slide. I am not sure how a 3d graphic would render, and I'mnot familiar with R or would not be able to offer any further advice, but you might start by trying to simply create a WebBrowser object inside your slide, and then tell it to Navigate to the HTML file.

Sub InsertHTMLFrame()
Dim sld as Slide
Dim shp as Shape
Dim wb as Object
Set sld = ActivePresentation.Slides(1) '## Modify as needed

'## Create the shape container, you will need to modify the L/T/W/H to fit your document
Set shp = sld.Shapes.AddOLEObject(100, 200, 200, 150, _
    "Shell.Explorer.2")
shp.Name = "3dgraphic"
Set wb = shp.OLEFormat.Object

wb.Navigate "C:\Users\you\Desktop\exported3dgraphic.html"
End Sub

Controlling this flow during SlideShow mode may be a little trickier, but it's doable, provided the graphic renders properly through IE like this.

How to Install This Macro

  1. Open your PowerPoint Presentation, and click Alt+F11 to bring up the Visual Basic project.
  2. Right-click the project in the left pane, and Insert Module:

enter image description here

  1. Paste the code from my answer in to this module.
  2. In the line that says wb.Navigate "C:\..." modify this to the correct file path for your HTML file. This can be on your computer or in a shared network folder, etc.

The browser should be able to display HTML pages when in SlideShow mode, but will not render them in the normal or preview mode.

David Zemens
  • 53,033
  • 11
  • 81
  • 130
  • Thank you for your contribution. I don't upvote because I am ignorant about html and then I don't understand any word :) – Stéphane Laurent Jun 07 '13 at 19:54
  • @StéphaneLaurent this isn't HTML per se, but it is a macro that might insert the HTML in to your powerpoint slide. I will update with some more detail on how to add this macro to your Presentation, and then we can see if it works for you. – David Zemens Jun 07 '13 at 20:02