[R] A question:How to plot hierarchical clustering with different colors?
yzzhao at mappi.helsinki.fi
yzzhao at mappi.helsinki.fi
Tue Nov 15 13:21:23 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
More information about the R-help
mailing list