Reputation: 3279
I'm beginner with plotting in 3D in R and I need help. I try to plot some easy paraboloid
library(rgl)
x <- seq(-1,1, 0.2)
y <- x
f <- function(x,y){
-(x^2+y^2)
}
z <- outer(x,y, "f")
persp3d(x, y, z, col="gray")
So, my questions are:
Can I draw only grid, or make color transparent to see also the part of "at the back"?
How to add points to the plot (on the surface, e.g to draw in other color point (1,1,2))?
Upvotes: 8
Views: 6488
Reputation: 226332
See ?material3d
for information on surface properties. Most of these properties, such as alpha
or front="line"
or back="line"
, can be passed directly to persp3d()
. Add points with points3d()
(or spheres3d()
).
persp3d(x, y, z, col="gray", alpha=0.5)
points3d(1,1,2,col="red")
persp3d(x, y, z, col="gray", front="line", back="line")
spheres3d(1,1,2,col="red",radius=5) ## appropriate radius: I used x <- y <- 1:20
Upvotes: 7