I have clustered some data in r
and plotted the results as a dendrogram. What i am trying to find out right now is how I can change the colour of the labels, so that labels that are the same have the same colour.
I got my dendrogram using the following code:
> d<-stringdist::stringdistmatrix(AR_GenesforR$AR_Genes)
> cl <-hclust(as.dist(d))
> plot(cl, label=AR_GenesforR$AR_Genes)
> groups <- cutree(cl, k=2)
> rect.hclust(cl, k=2, border="red")
The resulting dendrogram looks like this:
What I want to do now, is to colour all labels that are the same in the same colour, eg. all 2010
in yellow, all 2011
in blue and so on. I have researched quite a bit, but mostly only found ways to colour the labels according to the clusters they are in. Does someone know how I can do what I want?