Learn R Programming

e1071 (version 1.1-2)

plot.fclust: Plot Clustered Data

Description

Plot the data using different colors for each cluster. If x has more than 2 columns, a pairs plot is produced.

Usage

plot.fclust(clobj, x, centers=TRUE,
initcenters=FALSE, color=rainbow(clobj$learning$ncenters), ...)

Arguments

clobj
Object returned by a clustering algorithm such as cmeanscl
x
Data matrix
centers
Mark cluster centers with "X" (for 2-dimensional data only)
initcenters
Mark initial cluster centers with "+" (for 2-dimensional data only)
color
The color of the clusters plotted

See Also

cmeanscl, cshell, scaclust

Examples

Run this code
## a 2-dimensional example
x<-rbind(matrix(rnorm(100,sd=0.3),ncol=2),
         matrix(rnorm(100,mean=1,sd=0.3),ncol=2))
cl<-cmeanscl(x,2,20,verbose=TRUE,method="cmeans",m=2)
print(cl)
plot(cl,x)   

## a 3-dimensional example
x<-rbind(matrix(rnorm(150,sd=0.3),ncol=3),
         matrix(rnorm(150,mean=1,sd=0.3),ncol=3),
         matrix(rnorm(150,mean=2,sd=0.3),ncol=3))
cl<-cmeanscl(x,6,20,verbose=TRUE,method="cmeans")
print(cl)
plot(cl,x)

Run the code above in your browser using DataLab