Learn R Programming

DataVisualizations (version 1.1.8)

Plot3D: 3D plot of points

Description

A wrapper for Data with systematic clustering colors for either a 2D (x,y) or 3D (x,y,z) plot combined with a classification

Usage

Plot3D(Data,Cls,UniqueColors,size=2,na.rm=FALSE,…)

Arguments

Data

[1:n,1:d] matrix with either d=2 or d=3, if d>3 only the first 3 dimensions are taken

Cls

[1:n] numeric vector of the classification of data with k classes

UniqueColors

[1:k] character vector of colors, if not given DataVisualizations::DefaultColorSequence is used

size

size of points

na.rm

if na.rm=TRUE, then missing values are removed

further arguments to be processed by plot3d or geom_point

Details

For geom_point only size and na.rm is available as further arguments.

References

RGL vignette in https://cran.r-project.org/package=rgl

Spin3D in https://www.uni-marburg.de/fb12/arbeitsgruppen/datenbionik/software-en

Examples

Run this code
# NOT RUN {
#Spin3D similar output
data(Lsun3D)
Plot3D(Lsun3D$Data,Lsun3D$Cls,type='s',radius=0.1,box=FALSE,aspect=TRUE)
# }
# NOT RUN {
rgl::grid3d(c("x", "y", "z"))
# }
# NOT RUN {
#Projected Points with Classification
Data=cbind(runif(500,min=-3,max=3),rnorm(500))

# Classification
Cls=ifelse(Data[,1]>0,1,2)
Plot3D(Data,Cls,UniqueColors = DataVisualizations::DefaultColorSequence[c(1,3)],size=2)

# }
# NOT RUN {
#Points with Non-Overlapping Labels
#require(ggrepel)
Data=cbind(runif(30,min=-1,max=1),rnorm(30,0,0.5))
Names=paste0('VeryLongName',1:30)
ggobj=Plot3D(Data)
ggobj +  geom_text_repel(aes(label=Names), size=3)
# }

Run the code above in your browser using DataLab