title: Tree cut and Rectangles around clusters for a horizontal dendrogram in R
body: <p>I am trying to plot the results of a hierarchical clustering in <code>R</code> as a dendrogram, with rectangles identifying clusters. </p>
  
  <p>The following code does the trick for a vertical dendrogram, but for a horizontal dendrogram, (<code>horiz=TRUE</code>), the rectangles are not drawn. Is there any way to do the same for horizontal dendrograms too.</p>
  
  <pre><code>library("cluster")
  dst &lt;- daisy(iris, metric = c("gower"), stand = FALSE)
  hca &lt;- hclust(dst, method = "average")
  plot(as.dendrogram(hca), horiz = FALSE)
  rect.hclust(hca, k = 3, border = "red")
  </code></pre>
  
  <p>Moreover I would like to plot a line to cut the tree at a desired distance value. How to plot that in R. The <code>cutree</code> function returns the clusters, but is it possible to plot it as well.</p>
  
  <pre><code>cutree(hca, k = 3)
  </code></pre>
  
  <p>The desired output that I am looking for is like this.</p>
  
  <p><img src="https://i.stack.imgur.com/eL2yy.png" alt="dendrogram"></p>
  
  <p>How to get this done in R?</p>