jet.colors是对一个hte的Matlab调色板的R答案:
points = seq(-2, 0, length=20)
#create a grid
XY = expand.grid(X=points,Y=-points)
# A z-function
Zf
2./exp((X-.5)^2+Y^2)-2./exp((X+.5)^2+Y^2);
}
# populate a surface
Z
zlim
zlen
jet.colors
colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan",
"#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"))
colorzjet
require(rgl)
open3d()
rgl.surface(x=points, y=matrix(Z,20),
coords=c(1,3,2),z=-points,
color=colorzjet[ findInterval(Z, seq(min(Z), max(Z), length=100))] )
axes3d()
rgl.snapshot("copyMatlabstyle.png")
我会承认,使颜色与“Z轴”(实际上是rgl y轴)排列似乎非常不直观.如果您想要Matlab提供的闪亮,镜面效果,您可以发挥照明角度.
您还可以添加或删除照明:
clear3d(type = "lights")
light3d(theta=0, phi=0)
light3d(theta=0, phi=0) # twice as much light.
后:
grid3d("x")
grid3d("y")
grid3d("z")
rgl.snapshot("copyMatlabstyle3.png")
您可以将y格网格放置在表面之后:
grid3d("y+")
对axis3d或axis3d调用的类似调整可能会移动秤的位置.
有关更多示例,请查看http://rgm3.lab.nig.ac.jp/RGM/R_image_list并搜索“plot3d”,其中列出了R2BayesX :: plot3d函数的示例,还可以查看Karline Soetaert的plot3D软件包vignette,“50 ways to plot a volcano”