将点添加到 r 中的 3d 图 [英] Adding points to 3d plot in r

查看:31
本文介绍了将点添加到 r 中的 3d 图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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")

所以,我的问题是:

  1. 我可以只画网格,或者让颜色透明以看到在后面"的部分吗?

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

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

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

推荐答案

有关表面属性的信息,请参见 ?material3d.大多数这些属性,例如 alphafront="line"back="line",可以直接传递给 persp3d().使用 points3d()(或 spheres3d())添加点.

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 图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆