Interactive 3D in Shiny (shinyRGL)

The rgl package has been used to produce rich, interactive 3D graphics within R using the OpenGL framework for some time. The rgl authors also added the ability to export to WebGL, allowing R authors to produce interactive 3D graphics that were accessible from within any modern web browser.

This functionality can now be leveraged within the Shiny framework using the new shinyRGL package — allowing users of R who may have no prior web development experience to create interactive web applications which incorporate 3D graphics. Examples such as this 3D cube filled with variable numbers of points or this modification of the ‘bivar’ example included in rgl can be produced with minimal effort. (The source code for both of these applications is available in the /examples/ directory of the shinyRGL package; both are under 100 lines of code and are written entirely in R.)

The package was just released on CRAN and should now be available from your preferred CRAN mirror. You can install using the command:


Alternatively, you can download the bleeding-edge version of the code, view more details about the implementation, or track the development of the package on our GitHub repository. Please use GitHub to notify us of any issues or feature requests you may come across, as well.

Below is a sample of the kinds of graphics that can be produced using shinyRGL by writing only R code. Be sure to pan the scene by clicking and dragging, zoom using the scroll wheel, and even change the point of view by clicking and dragging with the right mouse button.

You must enable Javascript to view this page properly.


  1. maskonur says:

    > install.packages(“shinyRGL”)
    Warning in install.packages :
    package ‘shinyRGL’ is not available (for R version 3.0.2)

    • Jeff Allen says:

      It may take a day to trickle down to the CRAN mirror you’re using (it just got approved over the weekend). Can you try it again later today?

      Also, what Operating System are you using?

  2. Michael Kane says:

    Great package! I’ve submitted a pull request on GitHub to make the examples easier to run.

  3. Dan McCloskey says:

    Thanks for sharing this! I followed your initial post earlier this year and got rgl up and running on a headless server. Getting the second graph up was all the more easier with this integration. I’m looking to have the data points in my 3dplot show a pop-up window with a clickable link when you hover over them with a mouse. Any idea whether this would be possible with rgl plots?

    • Jeff Allen says:

      Glad it’s working for you! Unfortunately, ShinyRGL doesn’t really have the ability to extend beyond what RGL can render. Since RGL doesn’t offer the ability to handle mouse events, ShinyRGL can’t either. Certainly seems like a reasonable feature request for RGL, though! I’d love to see this added to the package.

  4. Morgan Boyce says:

    Hi Jeff, first I really appreciate your work creating shiny packages. I’m trying to use shinyRGL and am having some issues. I can run it on my windows machine using runApp(my_shiny_directory) but when i load it to my linux machine (Red Hat Enterprise Linux Server release 6.4 (Santiago) with shinyserver on it) I get the failed error even when i put options(rgl.useNULL=TRUE) before my server function. Any ideas how to fix this? Thank you very much!

    • Jeff Allen says:

      Hi Morgan. I recently heard reports that shinyRGL wasn’t playing nicely with the latest version of RGL. I’m hoping to look into that shortly, but in the mean time you might have better luck using my outdated fork of RGL: install_github(“rgl”, “trestletech”, “js-class”)

      If that doesn’t fix it, feel free to open an issue on GitHub:

      • Morgan Boyce says:

        Thanks Jeff I’ll see if that does the trick!

    • Yong says:

      I had the same problem and found a solution: first make sure the shiny app can access X11 (e.g. try put a system(‘xterm’) in server.r), then put rgl.init() somewhere in server.r at the beginning of shinyServer function.


  1. I did a map! | Katatrepsis - [...] of the data, and there are many neater ways to do this.  In particular, R gives the option to …

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">