【发布时间】:2014-02-28 22:32:44
【问题描述】:
以下取自 example(surface3d) 的代码不会产生任何结果:
library(rgl)
data(volcano)
z <- 2 * volcano # Exaggerate the relief
x <- 10 * (1:nrow(z)) # 10 meter spacing (S to N)
y <- 10 * (1:ncol(z)) # 10 meter spacing (E to W)
zlim <- range(y)
zlen <- zlim[2] - zlim[1] + 1
colorlut <- terrain.colors(zlen) # height color lookup table
col <- colorlut[ z-zlim[1]+1 ] # assign colors to heights for each point
open3d()
surface3d(x, y, z, color=col, back="lines")
【问题讨论】:
-
我没有在您的代码中看到库调用来加载具有这些功能的包。
-
在 open3d 调用之前将
require(rgl)添加到代码中可以在常规 Mac GUI 控制台和 RStudio 中成功。 -
为我工作。新的 RGL 设备已打开。
-
FWIW
library(rgl)和require(rgl)是多余的;你只需要一个或另一个。 (1) 您是否收到任何未告诉我们的错误或警告消息? (2) 你有安装 X11 吗? (3) 如果你在 base R 中运行(而不是通过 RStudio)会发生什么? -
是否打开了 RGL 设备(在新窗口中,而不是 RStudio 设备)?
标签: r plot 3d rstudio geometry-surface