Learn R Programming

TDA (version 1.0)

plot.clusterTree: Plots the Cluster Tree

Description

This function plots the Cluster Tree stored in an object of class clusterTree.

Usage

## S3 method for class 'clusterTree':
plot(x, type = "lambda", color = NULL, add = FALSE, ...)

Arguments

x
an object of class clusterTree. (see clusterTree)
type
string: if "lambda", then the lambda Tree is plotted. if "kappa", then the kappa Tree is plotted.
color
the color of the branches of the Cluster Tree
add
logical: if TRUE the Tree is added to an existing plot.
...
additional graphical parameters.

References

Brian P. Kent, Alessandro Rinaldo, and Timothy Verstynen, (2013), "DeBaCl: A Python Package for Interactive DEnsity-BAsed CLustering."arXiv:1307.8136

Fabrizio Lecci, Alessandro Rinaldo, and Larry Wasserman, (2014), "Metric Embeddings for Cluster Trees"

See Also

clusterTree, print.clusterTree

Examples

Run this code
## Generate data: 3 clusters
n=1200    #sample size
Neach=floor(n/4) 
X1=cbind(rnorm(Neach,1,.8),rnorm(Neach,5,0.8))
X2=cbind(rnorm(Neach,3.5,.8),rnorm(Neach,5,0.8))
X3=cbind(rnorm(Neach,6,1),rnorm(Neach,1,1))
XX=rbind(X1,X2,X3)

k=100     #parameter of knn

## Density clustering using knn and kde
Tree=clusterTree(XX,k, density="knn")
TreeKDE=clusterTree(XX,k,h=0.3, density="kde")

par(mfrow=c(2,3))
plot(XX, pch=19, cex=0.6)
# plot lambda trees
plot(Tree, type="lambda", main="lambda Tree (knn)")
plot(TreeKDE, type="lambda", main="lambda Tree (kde)")
# plot clusters
plot(XX, pch=19, cex=0.6, main="cluster labels")
for (i in Tree$id){
	points(matrix(XX[Tree$DataPoints[[i]],],ncol=2), col=i, pch=19, cex=0.6)
}
#plot kappa trees
plot(Tree, type="kappa", main="kappa Tree (knn)")
plot(TreeKDE, type="kappa", main="kappa Tree (kde)")

Run the code above in your browser using DataLab