title: Colorize Clusters in Dendogram with ggplot2
body: <p>Didzis Elferts showed how to plot a dendogram using ggplot2 and ggdendro:</p>
  
  <p><a href="https://stackoverflow.com/questions/14118033/horizontal-dendrogram-in-r-with-labels">horizontal dendrogram in R with labels</a></p>
  
  <p>here is the code:</p>
  
  <pre><code>labs = paste("sta_",1:50,sep="") #new labels
  rownames(USArrests)&lt;-labs #set new row names
  hc &lt;- hclust(dist(USArrests), "ave")
  
  library(ggplot2)
  library(ggdendro)
  
  #convert cluster object to use with ggplot
  dendr &lt;- dendro_data(hc, type="rectangle") 
  
  #your own labels are supplied in geom_text() and label=label
  ggplot() + 
    geom_segment(data=segment(dendr), aes(x=x, y=y, xend=xend, yend=yend)) + 
    geom_text(data=label(dendr), aes(x=x, y=y, label=label, hjust=0), size=3) +
    coord_flip() + scale_y_reverse(expand=c(0.2, 0)) + 
    theme(axis.line.y=element_blank(),
          axis.ticks.y=element_blank(),
          axis.text.y=element_blank(),
          axis.title.y=element_blank(),
          panel.background=element_rect(fill="white"),
          panel.grid=element_blank())
  </code></pre>
  
  <p>Does anyone know, how to colorize the different clusters? For example, you want to have 2 Clusters (k=2) colorized?</p>