## Simple illustration of a calibrated density axis biplot
x<-PCAbiplot(iris[,-5],group=iris[,5])
TDAbiplot(x,dist=1,inflate=1)
## Change the plotting characters of class-groups:
y<- x |> TDAbiplot(dist=1,inflate=1,symbol=c("circle","diamond","square"))
## Custom kernel densities can be drawn on the axes:
density.args<-list()
density.args$kernel <- "optcosine"
density.args$bw <- "sj"
y<- x |> TDAbiplot(dist=1,inflate=1,density.args=density.args)
## To lessen the effects of outliers, a smaller alpha-ellipse can be
## used to determine axis lengths. Define a function that strips away
## outliers, for example a convex hull peeling algorithm:
HullPeeling <- function(x,alpha) {
n<-nrow(x)
propinside<-1
target<-1-alpha
x2<-x
while (propinside>target) {
hull<-grDevices::chull(x2)
x2old<-x2
x2<-x2[-hull,]
propinside<-nrow(x2)/n
}
return(x2[grDevices::chull(x2),])
}
y<- x |> TDAbiplot(dist=1,inflate=1, alpha_Elip=HullPeeling, alpha=0.4)
Run the code above in your browser using DataLab