在r中添加点到3d图

时间:2021-09-11 20:36:05

I'm beginner with plotting in 3D in R and I need help. I try to plot some easy paraboloid

我是初学者,在R中用3D绘图,我需要帮助。我试图绘制一些简单的抛物面

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:

所以,我的问题是:

  1. Can I draw only grid, or make color transparent to see also the part of "at the back"?

    我可以只绘制网格,还是使颜色透明,还可以看到“在后面”的部分?

  2. How to add points to the plot (on the surface, e.g to draw in other color point (1,1,2))?

    如何在绘图上添加点(在表面上,例如以其他颜色点(1,1,2)绘制)?

1 个解决方案

#1


5  

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()).

有关表面属性的信息,请参见?material3d。大多数这些属性,例如alpha或front =“line”或back =“line”,可以直接传递给persp3d()。使用points3d()(或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

#1


5  

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()).

有关表面属性的信息,请参见?material3d。大多数这些属性,例如alpha或front =“line”或back =“line”,可以直接传递给persp3d()。使用points3d()(或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

相关文章