I would like to plot my 3D function in a rgl device window using plot3D
package. It allows me to rotate on x, y, z axis and scale. This is basic example with rgl
package:
x <- seq(-10, 10, length = 30)
y <- x
z <- outer(x, y, function(x, y) { r <- sqrt(x^2 + y^2); 10 * sin(r)/r })
z[is.na(z)] <- 1
rgl::persp3d(x, y, z)
Unfortunately this one is not open in rgl device:
plot3D::persp3D(x, y, z)
I am pretty sure that I have see it somewhere (maybe even in my experiments with that package). Can someone help me please?
tl;dr maybe you were looking for the plot3Drgl
package?
I don't think this is possible. ?plot3D::persp3D
says
‘persp3D’ is an extension to the default persp plot
(emphasis added). The "default persp
plot" is built on the base R graphics, which uses a static "canvas-style" model - it cannot be dynamically rotated/zoomed.
Let's try looking for other packages with "3D" in their name ...
a1 <- available.packages()
grep("3D",rownames(a1),value=TRUE)
## [1] "arf3DS4" "BaTFLED3D" "DGVM3D" "FPCA3D"
## [5] "plot3D" "plot3Drgl" "VecStatGraphs3D"
We can try plot3Drgl
, whose documentation (?plot3Drgl
) says
It will plot most (but not all) features from plots generated with ‘plot3D’, except for the color keys and polygons.
On the other hand, it looks from experimentation as though it does handle color keys ...
plot3Drgl::persp3Drgl(x,y,z)