surface3js | R Documentation |
This function behaves very similarly to the surface3d
function in the rgl
package, although the handling of NA values are handled differently.
surface3js(
data3js,
x,
y,
z,
col = "black",
mat,
wireframe = FALSE,
highlight,
...
)
data3js |
The data3js object |
x |
Values corresponding to rows of z, or matrix of x coordinates |
y |
Values corresponding to the columns of z, or matrix of y coordinates |
z |
Matrix of heights |
col |
The color of the surface as either a single value, vector or matrix. |
mat |
The material to use when drawing the matrix, for a solid surface the default is "phong", for a wireframe the default is "line". |
wireframe |
Logical value for if the surface should be displayed as a mesh |
highlight |
highlight attributes (see |
... |
Material and texture properties. See |
Returns an updated data3js object
Other plot components:
arrows3js()
,
axis3js()
,
box3js()
,
grid3js()
,
legend3js()
,
light3js()
,
lines3js()
,
mtext3js()
,
points3js()
,
segments3js()
,
shape3js()
,
sphere3js()
,
text3js()
,
triangle3js()
# volcano example taken from "persp"
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(z)
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
p <- plot3js(
xlim = range(x),
ylim = range(y),
zlim = range(z),
label_axes = FALSE,
aspect = c(1, 1, 1) # Maintain a constant aspect ratio
)
p <- surface3js(
data3js = p,
x, y, z,
col = col
)
r3js(
data3js = p,
rotation = c(-1.15, 0, -0.65),
zoom = 1.5
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.