3D plot in R

Recently, I wanted to examine the relationship of multiple variables at the same time, and naturally I needed a 3D plot. I never made 3D plot in R. When I had a google search, I found many packages in R which can be used to make 3D plots. The top ones are rgl, plotly, scatterplot3d, and rggobi. I have not compared them in details, but I have gotten some impression of features of different packages. I may write another post in future when I have more experience.

1. rgl. This is an R interface to OpenGL library. It can produce interactive 3D plots, including points, surfaces, lines, etc. The drawback is that not all the plots can be saved in a high resolution because the rgl.postscript() seems not able to save scatter plot (not tested others yet). rgl.snapshot() can save figures correctly, but only in ‘png’ format. And the resolution is limited, although the display window can be set with open3d(windowRect=c( left, top, right, bottom)) in pixels.

2. plotly. This is an interface to plotly project (written in python?). The advantage of this package is that many types of plots can be generated and be saved in different formats, and the plots can be rotatable and embedded into website by converting to javascript. When a plot is made locally, it is automatically uploaded to the workspace of the plotly website where the plots can be further edited. When I made a surface plot, I failed, because it seems that the surface plot can be only made when the X and Y variables are integer or categorical. I am still trying to understand the format of input data. You always need the plotly website available to view the result of the plot; no local files are generated.

3. scatterplot3d. This package can only make scatterplot in 3D and is static, so it is only useful in certain conditions.

4. rggobi. I have not tried this package, yet. Probably I will not, because I feel the above 3 packages are sufficient for my work.

Welcome to share your experience of 3D plots.

6 Replies to “3D plot in R”

  1. Doess your site hhave a contact page? I’m having problems locating it but, I’d like to
    shoot you an e-mail. I’ve got some suggestions for your blog you
    might be inferested in hearing. Either way, great blog and I look forward to
    seeing it improvve over time.

  2. I do have a contact page under the ‘Contact’ tab. Please send me your suggestions through email. Thanks.

Comments are closed.