Utilities for easily building and customizing 3D graphs in R.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Load dataset
data(iris)
x <- iris$Sepal.Length
y <- iris$Petal.Length
z <- iris$Sepal.Width
library("rgl")
# Quick scatter plots
# ++++++++++++++++
rgl_scatter(iris, groups = iris$Species)
# Scale data
rgl_scatter(iris, groups = iris$Species, data.scale = TRUE)
# Remove the bounding box
rgl_scatter(iris, groups = iris$Species, show.bbox = FALSE)
# Add ellipses
rgl_scatter(iris, groups = iris$Species,
show.bbox = FALSE, add.ellipse = TRUE)
# Build RGL scatter plot
# +++++++++++++++++++
rgl_init()
rgl.spheres(x, y, z, r = 0.2, color = get_colors(iris$Species))
rgl_add_axes(x, y, z, show.bbox = TRUE)
rgl_add_ellipses(x, y, z, groups = iris$Species)
aspect3d(1,1,1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.