knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
if(!require(devtools)) install.packages("devtools") devtools::install_github("kassambara/graph3d")
library(graph3d)
require(rgl) data(iris) x <- iris$Sepal.Length y <- iris$Petal.Length z <- iris$Sepal.Width
knitr::knit_hooks$set(rgl=knitr::hook_rgl)
rgl_scatter(iris, groups = iris$Species, add.ellipse = TRUE, data.scale = TRUE)
Remove the bounding box:
rgl_scatter(iris, groups = iris$Species, show.bbox = FALSE)
Add regression planes
rgl_scatter(iris, groups = iris$Species, show.bbox = FALSE, add.reg.planes = TRUE)
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)
The function s3d_addgrids() can be used as follow:
library("scatterplot3d") data(iris) # Basic 3d graphics scatterplot3d(iris[,1:3]) # Remove box and add grids scatterplot3d(iris[, 1:3], pch = 16, grid = TRUE, box = FALSE) s3d_addgrids(iris[, 1:3], grid = c("xy", "xz", "yz"))
par(mar =c(1,1,2,1)) # quakes dataset data("quakes") dist3d(quakes$long, quakes$lat, colvar=quakes$depth, breaks = 30, col.bar = "steelblue") # Iris dataset dist3d(iris$Sepal.Length, iris$Petal.Width, col.bar = "steelblue", colvar=as.numeric(iris$Species))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.