title: how to plot and annotate hierarchical clustering dendrograms in scipy/matplotlib
body: <p>I'm using <code>dendrogram</code> from <code>scipy</code> to plot hierarchical clustering using <code>matplotlib</code> as follows:</p>
  
  <pre><code>mat = array([[1, 0.5, 0.9],
               [0.5, 1, -0.5],
               [0.9, -0.5, 1]])
  plt.subplot(1,2,1)
  plt.title("mat")
  dist_mat = mat
  linkage_matrix = linkage(dist_mat,
                           "single")
  print "linkage2:"
  print linkage(1-dist_mat, "single")
  dendrogram(linkage_matrix,
             color_threshold=1,
             labels=["a", "b", "c"],
             show_leaf_counts=True)
  plt.subplot(1,2,2)
  plt.title("1 - mat")
  dist_mat = 1 - mat
  linkage_matrix = linkage(dist_mat,
                           "single")
  dendrogram(linkage_matrix,
             color_threshold=1,
             labels=["a", "b", "c"],
             show_leaf_counts=True)
  </code></pre>
  
  <p>My questions are: first, why does <code>mat</code> and <code>1-mat</code> give identical clusterings here? and second, how can I annotate the distance along each branch of the tree using <code>dendrogram</code> so that the distances between pairs of nodes can be compared?</p>
  
  <p>finally it seems that <code>show_leaf_counts</code> flag is ignored, is there a way to turn it on so that the number of objects in each class is shown?  thanks.<img src="https://i.stack.imgur.com/fHMDa.png" alt="enter image description here"></p>