Plot3D: 3D plot of points

Plot3DR Documentation

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,Plotter3D="rgl",...)

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, for plotly additional a vector [1:n] of a mapping of sizes to Cls has to be given in the (...) argument with sizes=

na.rm

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

Plotter3D

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"

Details

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

Note

Uses either geom_point for 2D or plot3d for 3D or plot_ly

Author(s)

Michael Thrun

References

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

Examples

#Spin3D similar output

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)

## 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)

## End(Not run)

DataVisualizations documentation built on Oct. 10, 2023, 9:06 a.m.