Using demo/examples as a reference guide to some graphics packages:
library(scatterplot3d)
## Warning: package 'scatterplot3d' was built under R version 3.2.2
example(scatterplot3d)
##
## scttr3> ## On some devices not all colors can be displayed.
## scttr3> ## Try the postscript device or use highlight.3d = FALSE.
## scttr3>
## scttr3> ## example 1
## scttr3> z <- seq(-10, 10, 0.01)
##
## scttr3> x <- cos(z)
##
## scttr3> y <- sin(z)
##
## scttr3> scatterplot3d(x, y, z, highlight.3d=TRUE, col.axis="blue",
## scttr3+ col.grid="lightblue", main="scatterplot3d - 1", pch=20)
##
## scttr3> ## example 2
## scttr3> temp <- seq(-pi, 0, length = 50)
##
## scttr3> x <- c(rep(1, 50) %*% t(cos(temp)))
##
## scttr3> y <- c(cos(temp) %*% t(sin(temp)))
##
## scttr3> z <- c(sin(temp) %*% t(sin(temp)))
##
## scttr3> scatterplot3d(x, y, z, highlight.3d=TRUE,
## scttr3+ col.axis="blue", col.grid="lightblue",
## scttr3+ main="scatterplot3d - 2", pch=20)
##
## scttr3> ## example 3
## scttr3> temp <- seq(-pi, 0, length = 50)
##
## scttr3> x <- c(rep(1, 50) %*% t(cos(temp)))
##
## scttr3> y <- c(cos(temp) %*% t(sin(temp)))
##
## scttr3> z <- 10 * c(sin(temp) %*% t(sin(temp)))
##
## scttr3> color <- rep("green", length(x))
##
## scttr3> temp <- seq(-10, 10, 0.01)
##
## scttr3> x <- c(x, cos(temp))
##
## scttr3> y <- c(y, sin(temp))
##
## scttr3> z <- c(z, temp)
##
## scttr3> color <- c(color, rep("red", length(temp)))
##
## scttr3> scatterplot3d(x, y, z, color, pch=20, zlim=c(-2, 10),
## scttr3+ main="scatterplot3d - 3")
##
## scttr3> ## example 4
## scttr3> my.mat <- matrix(runif(25), nrow=5)
##
## scttr3> dimnames(my.mat) <- list(LETTERS[1:5], letters[11:15])
##
## scttr3> my.mat # the matrix we want to plot ...
## k l m n o
## A 0.4764872 0.25337407 0.73801305 0.28917059 0.8121223
## B 0.1793855 0.98272754 0.45645114 0.85288314 0.9913498
## C 0.8246973 0.31283099 0.12011753 0.34272849 0.1201433
## D 0.3363592 0.07063017 0.44071263 0.40412627 0.7745041
## E 0.8985806 0.60986259 0.07498873 0.05257479 0.1744542
##
## scttr3> s3d.dat <- data.frame(cols=as.vector(col(my.mat)),
## scttr3+ rows=as.vector(row(my.mat)),
## scttr3+ value=as.vector(my.mat))
##
## scttr3> scatterplot3d(s3d.dat, type="h", lwd=5, pch=" ",
## scttr3+ x.ticklabs=colnames(my.mat), y.ticklabs=rownames(my.mat),
## scttr3+ color=grey(25:1/40), main="scatterplot3d - 4")
##
## scttr3> ## example 5
## scttr3> data(trees)
##
## scttr3> s3d <- scatterplot3d(trees, type="h", highlight.3d=TRUE,
## scttr3+ angle=55, scale.y=0.7, pch=16, main="scatterplot3d - 5")
##
## scttr3> # Now adding some points to the "scatterplot3d"
## scttr3> s3d$points3d(seq(10,20,2), seq(85,60,-5), seq(60,10,-10),
## scttr3+ col="blue", type="h", pch=16)
##
## scttr3> # Now adding a regression plane to the "scatterplot3d"
## scttr3> attach(trees)
##
## scttr3> my.lm <- lm(Volume ~ Girth + Height)
##
## scttr3> s3d$plane3d(my.lm, lty.box = "solid")
##
## scttr3> ## example 6; by Martin Maechler
## scttr3> cubedraw <- function(res3d, min = 0, max = 255, cex = 2, text. = FALSE)
## scttr3+ {
## scttr3+ ## Purpose: Draw nice cube with corners
## scttr3+ cube01 <- rbind(c(0,0,1), 0, c(1,0,0), c(1,1,0), 1, c(0,1,1), # < 6 outer
## scttr3+ c(1,0,1), c(0,1,0)) # <- "inner": fore- & back-ground
## scttr3+ cub <- min + (max-min)* cube01
## scttr3+ ## visibile corners + lines:
## scttr3+ res3d$points3d(cub[c(1:6,1,7,3,7,5) ,], cex = cex, type = 'b', lty = 1)
## scttr3+ ## hidden corner + lines
## scttr3+ res3d$points3d(cub[c(2,8,4,8,6), ], cex = cex, type = 'b', lty = 3)
## scttr3+ if(text.)## debug
## scttr3+ text(res3d$xyz.convert(cub), labels=1:nrow(cub), col='tomato', cex=2)
## scttr3+ }
##
## scttr3> ## 6 a) The named colors in R, i.e. colors()
## scttr3> cc <- colors()
##
## scttr3> crgb <- t(col2rgb(cc))
##
## scttr3> par(xpd = TRUE)
##
## scttr3> rr <- scatterplot3d(crgb, color = cc, box = FALSE, angle = 24,
## scttr3+ xlim = c(-50, 300), ylim = c(-50, 300), zlim = c(-50, 300))
##
## scttr3> cubedraw(rr)
##
## scttr3> ## 6 b) The rainbow colors from rainbow(201)
## scttr3> rbc <- rainbow(201)
##
## scttr3> Rrb <- t(col2rgb(rbc))
##
## scttr3> rR <- scatterplot3d(Rrb, color = rbc, box = FALSE, angle = 24,
## scttr3+ xlim = c(-50, 300), ylim = c(-50, 300), zlim = c(-50, 300))
##
## scttr3> cubedraw(rR)
##
## scttr3> rR$points3d(Rrb, col = rbc, pch = 16)