geo_shapes <- c(
"circle", "square", "triangle",
"circle open", "square open", "triangle open",
"circle filled", "square filled", "triangle filled",
"sphere", "cube", "tetrahedron",
"cube open",
"cube filled"
)
gl_shapes <- c(
"circle", "square", "triangle",
"circle open", "square open", "triangle open",
"circle filled", "square filled", "triangle filled",
"sphere"
)
# Setup base plot
p <- plot3js(
xlim = c(0, length(geo_shapes) + 1),
ylim = c(-4, 4),
zlim = c(-4, 4),
label_axes = FALSE
)
# Plot the different point geometries
p <- points3js(
data3js = p,
x = seq_along(geo_shapes),
y = rep(0, length(geo_shapes)),
z = rep(0, length(geo_shapes)),
size = 2,
shape = geo_shapes,
col = rainbow(length(geo_shapes)),
fill = "grey70"
)
r3js(p, rotation = c(0, 0, 0), zoom = 2)
# Setup base plot
p <- plot3js(
xlim = c(0, length(gl_shapes) + 1),
ylim = c(-4, 4),
zlim = c(-4, 4),
label_axes = FALSE
)
# Plot the different gl points
p <- points3js(
data3js = p,
x = seq_along(gl_shapes),
y = rep(0, length(gl_shapes)),
z = rep(0, length(gl_shapes)),
size = 2,
shape = gl_shapes,
col = rainbow(length(gl_shapes)),
fill = "grey50",
geometry = FALSE
)
r3js(p, rotation = c(0, 0, 0), zoom = 2)
# Plot a 10,000 points using the much more efficient gl.point representation
# Setup base plot
p <- plot3js(
xlim = c(-4, 4),
ylim = c(-4, 4),
zlim = c(-4, 4),
label_axes = FALSE
)
p <- points3js(
data3js = p,
x = rnorm(10000, 0),
y = rnorm(10000, 0),
z = rnorm(10000, 0),
size = 0.6,
col = rainbow(10000),
shape = "sphere",
geometry = FALSE
)
r3js(p, rotation = c(0, 0, 0), zoom = 2)
Run the code above in your browser using DataLab