问题描述
我是初学者,在3D中绘制R,我需要帮助。我尝试绘制一些简单的抛物线b
$ p $ lt; code> library(rgl)
x< - seq(-1,1,0.2 )
y< - x
f< - 函数(x,y){
- (x ^ 2 + y ^ 2)
}
z< - 外层(x,y,f)
persp3d(x,y,z,col =gray)
所以,我的问题是:
-
我可以只绘制网格,还可以让颜色透明在后面的部分?
-
如何给曲线添加点(在曲面上,例如绘制其他色点(1,1 ,2))?
material3d 获取表面属性的信息。大多数这些属性,如 alpha 或 front =line或 back =行,可以直接传递给 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 )##适当的半径:我用x
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))?
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
这篇关于在r中添加点到3d图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!