简体   繁体   English

在R中的3D图上添加点

[英]Adding points to 3d plot in r

I'm beginner with plotting in 3D in R and I need help. 我是R中3D绘图的初学者,我需要帮助。 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: 因此,我的问题是:

  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, eg to draw in other color point (1,1,2))? 如何在图上添加点(在表面上,例如绘制其他色点(1,1,2))?

See ?material3d for information on surface properties. 有关表面特性的信息,请参见?material3d Most of these properties, such as alpha or front="line" or back="line" , can be passed directly to persp3d() . 这些属性中的大多数(例如alphafront="line"back="line" )都可以直接传递给persp3d() Add points with points3d() (or spheres3d() ). 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM