Open Source Software

Demonstration of Interactive Graphics Using rgl

A picture is worth a thousand words, or perhaps ten thousand. One of R’s strengths is the ease of generating easy to use and understand graphics and visualizations. At a recent meeting of the DFW Data Visualizations and Infographics Meetup, I gave a 15 minute demonstration of R as part of the demo night for several data visualization packages, including D3, Tableu, R, a tool developed by the Dallas Morning News, and MicroStrategies. For my demonstration of R, I reviewed a few graphics and visualization techniques in R that are unusual in comparison to the other graphics tools being demonstrated:

  • Sweave, odfWeave, and Knitr as ways to generate combined text and graphics where the text can use values generated on the fly in the code. This is very helpful when creating reports where the numbers change depending upon the data set used.
  • The package ggplot2 in general and the use of the ggthemes package to change the look and feel of a plot. This capability is very useful when you need to generate the same plot for muliple style guides.
  • The ggmap package for generating contour maps of arbitrary data–in this case Dallas Police Department call data.
  • The rgl package for creating interactive graphics. Rgl is unusual in that it allows multiple intersecting surfaces to be generated easily.

There are many examples of ggplot graphics elsewhere on this web site, so I’m not going to include an example of ggplot graphics here. I do not have any examples of rgl generated visualizations, and feel it would be useful to include one here. The rgl package is one of the few packages that allow you to easily include intersecting surfaces, for example the parabola and intersecting plane shown in the visualization below.

The rgl package allows you to export the graphic item for web use in three files–one .html file, one .js file, and one .png file; the .png file is used to display an image and error message when JavaScript is not enabled. For this web page, I modified and combined the files to simplify inclusion on this web site.

The chart below is interactive; use your mouse to rotate and flip the graphic to see the intersecting surfaces more easily.

You must enable Javascript to view this page properly.

Drag mouse to rotate model. Use mouse wheel or middle button to zoom it.

Object written from rgl 0.93.986 by writeWebGL.

This web site uses cookies to provide user authentication and improve your user experience through the use of Google Analytics and Matomo Analytics. It also uses contact information for email and phone communcation. For details, see the Privacy Policy.