Hi,
Which packages and functions can be used in R for making 3D plots of our data (interactive in some way (such as rotation along axes)) ?
Thanks
Hi,
Which packages and functions can be used in R for making 3D plots of our data (interactive in some way (such as rotation along axes)) ?
Thanks
There are a number of functions to plot data in three dimensions, such as persp() and wireframe(), which
draw surfaces, and cloud(), which draws three-dimensional scatter plots. There are many more.
For wireframe() and cloud(), one loads the lattice library. Here is an example:
Hope this helps!
i mostly use the GUI Rcmdr for making a 3 D Plot in 3 clicks!! you can see the video here
or just try this code
> data(iris3, package="datasets")
> iris3 <- as.data.frame(iris3)
> names(iris3) <- make.names(names(iris3))
> library(rgl, pos=4)
> library(mgcv, pos=4)
> scatter3d(iris3$Petal.W..Setosa, iris3$Petal.L..Setosa, + iris3$Sepal.L..Setosa, fit="linear", residuals=TRUE, bg="black", + axis.scales=TRUE, grid=TRUE, ellipsoid=FALSE, xlab="Petal.W..Setosa", + ylab="Petal.L..Setosa", zlab="Sepal.L..Setosa")
> scatter3d(iris3$Petal.L..Versicolor, iris3$Petal.L..Setosa, + iris3$Petal.L..Virginica, fit="linear", residuals=TRUE, bg="white", + axis.scales=TRUE, grid=TRUE, ellipsoid=FALSE, xlab="Petal.L..Versicolor", + ylab="Petal.L..Setosa", zlab="Petal.L..Virginica")
> rgl.snapshot("C:/Documents and Settings/abc/Desktop/RGLGraph.png")
Hello,
There are some other alternatives:
The “rgl” package offers what you are looking for to rotate (automatically) a 3D function. Also its rendering/shadowing is quite powerful.
There is another package “plot3D” which can be combined with package “animation” to create 3D graphs. “plot3d” works with parametric functions. You can customize the view point to see it from different perspectives.
And if what you have is a set of point, you can use “scatterplot3d” package, its result is not so attractive, nice as the other two packages.
Regards,
Carlos.