A wrapper for Data with systematic clustering colors for either a 2D (x,y) or 3D (x,y,z) plot combined with a classification
Plot3D(Data,Cls,UniqueColors,size=2,na.rm=FALSE,Plotter3D="rgl",...)
[1:n,1:d] matrix with either d=2
or d=3
, if d>3
only the first 3 dimensions are taken
[1:n] numeric vector of the classification of data with k
classes
[1:k] character vector of colors, if not given DataVisualizations::DefaultColorSequence is used
size of points, for plotly additional a vector [1:n] of a mapping of sizes to Cls has to be given in the (...) argument with sizes=
if na.rm=TRUE
, then missing values are removed
in case of 3 dimensions, choose either "plotly" or "rgl",
if one of this packages is not given, the other one is selected as a fallback method
further arguments to be processed by plot3d
or geom_point
or plot_ly
of type "scatter3d"
Michael Thrun
For geom_point
only size
and na.rm
is available as further arguments.
RGL vignette in https://cran.r-project.org/package=rgl
#Spin3D similar output
# \donttest{
data(Lsun3D)
Plot3D(Lsun3D$Data,Lsun3D$Cls,type='s',radius=0.1,box=FALSE,aspect=TRUE)
rgl::grid3d(c("x", "y", "z"))
# }
#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)
if (FALSE) {
#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