[R] How to plot hierarchical clustering with different colors?

yzzhao yan.zhao at helsinki.fi
Tue Nov 15 13:14:33 CET 2011


Dear experts,

I would like to plot a hierarchical clustering of 300 items. I had a
distance matrix with dimension of 300*300. The 300 items were from 7 groups
which I would like to label with 7 different colours in the plot. 

>h<-hclust(as.dist(300_distance_matrix))
>plot(h,hang=-1,cex=0.5, col="blue")

I used the above script to plot the result. The cluster was all blue, the
300 item names were all displayed blue. When I tried to specify the seven
different colours, I found there was no option to get the names to be
displayed in different colours. 

When I used graph and Rgraphviz packages, I could define a attribute list to
specify the different group colours and plot a colourful graph. Is there any
options in hierarchical clustering to do the same? Could someone kindly help
me with this problem? Thanks in advance.


Sincerely
Yan

--
View this message in context: http://r.789695.n4.nabble.com/How-to-plot-hierarchical-clustering-with-different-colors-tp4042734p4042734.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list