# How to produce a pretty plot of the results of k-means cluster analysis?

I'm using R to do K-means clustering. I'm using 14 variables to run K-means

• What is a pretty way to plot the results of K-means?
• Are there any existing implementations?
• Does having 14 variables complicate plotting the results?

I found something called GGcluster which looks cool but it is still in development. I also read something about sammon mapping, but didn't understand it very well. Would this be a good option?

-
If for some reason you are concerned with the present solutions for this very practical problem, please consider adding comments to existing replies or update your post with more context. Working with 40,000 cases is an important information here. –  chl Jun 27 '12 at 19:57
Another example with 11 classes and 10 variables is on page 118 of Elements of Statistical Learning; not terribly informative. –  denis Nov 4 at 16:56

I'd push the silhouette plot for this, because it's unlikely that you'll get much actionable information from pair plots when the number of dimension is 14.

library(cluster)
library(HSAUR)
data(pottery)
km <- kmeans(pottery,3)
dissE <- daisy(pottery)
dE2 <- dissE^2
sk2 <- silhouette(km$cl, dE2) plot(sk2)  This approach is highly cited and well known (see here for an explanation). Rousseeuw, P.J. (1987) Silhouettes: A graphical aid to the interpretation and validation of cluster analysis. J. Comput. Appl. Math., 20, 53-65. - I like this. I'll look further into it. Thank you. – JEquihua Jun 25 '12 at 20:39 add comment Here an example that can helps you: library(cluster) library(fpc) data(iris) dat <- iris[, -5] # without known classification # Kmeans clustre analysis clus <- kmeans(dat, centers=3)  # Fig 01 plotcluster(dat, clus$cluster)


# More complex
clusplot(dat, clus$cluster, color=TRUE, shade=TRUE, labels=2, lines=0)  # Fig 03 with(iris, pairs(dat, col=c(1:3)[clus$cluster]))


Based on the latter plot you could decide which of your initial variables to plot. Maybe 14 variables are huge, so you can try a principal component analysis (PCA) before and then use the first two or three components from the PCA to perform the cluster analysis.

-