pet*_*ete 15
你可以试试这个vrmlgen包.它将生成可以使用浏览器插件显示的3d VRML文件; 你可以在VRML插件和浏览器检测器中找到一个插件.
安装插件后,请尝试以下操作:
require(vrmlgen)
example(bar3d)
Run Code Online (Sandbox Code Playgroud)
注意:示例代码没有在我的浏览器中自动打开(RStudio,Win7,Chrome),因为路径被破坏了.您可能需要使用:
require(stringr)
browseURL(str_replace_all(file.path(outdir, 'barplot.html'), fixed('\\'), '/'))
Run Code Online (Sandbox Code Playgroud)
如果您不想安装VRML插件,则可以使用X3DOM.您需要一个转换器,但您的用户应该只能使用(现代)浏览器查看它们.您可能必须修改以下代码才能获得正确的路径:
setwd(outdir)
aopt <- 'C:/PROGRA~1/INSTAN~1/bin/aopt' # Path to conversion program
vrml <- 'barplot.wrl'
x3dom <- 'barx.html'
command <- paste(aopt, '-i', vrml, '-N', x3dom)
system(command)
# LOG Avalon Init: 47/616, V2.0.0 build: R-21023 Jan 12 2011
# LOG Avalon Read url
# LOG Avalon Read time: 0.074000
# ============================================
# Call: writeHTML with 1 param
# Write raw-data to barx.html as text/html
# WARNING Avalon Run NodeNameSpace "scene" destructor and _nodeCount == 3
# WARNING Avalon Try to remove nodes from parents
# WARNING Avalon PopupText without component, cannot unregister
# WARNING Avalon Avalon::exitSystem() call and node/obj left: 0/3331
browseURL(file.path(outdir, 'barx.html'))
setwd(curdir)
Run Code Online (Sandbox Code Playgroud)
小智 13
对于一个简单的解决方
x <- sort(rnorm(1000))
y <- rnorm(1000)
z <- rnorm(1000) + atan2(x,y)
plot3d(x,y,z,
col=rainbow(1000),
type = "s",
size=1,
xlab = "x",
ylab = "y",
zlab = "z",
box=T)
# This writes a copy into temporary directory 'webGL', and then displays it
browseURL(paste("file://", writeWebGL(dir=file.path("C:/Your-Directory-Here/", "webGL"), width=700), sep=""))
Run Code Online (Sandbox Code Playgroud)
在Firefox或类似的支持HTML5和WebGL的浏览器中打开index.html文件