title: How do I create a radial cluster like the following code-example in Python?
body: <p>I've found several examples on how to create these exact hierarchies (at least I believe they are) like the following here <a href="https://stackoverflow.com/questions/2982929/plotting-results-of-hierarchical-clustering-ontop-of-a-matrix-of-data-in-python">stackoverflow.com/questions/2982929/</a> which work great, and almost perform what I'm looking for. </p>
  
  <p>[EDIT]Here's a simplified version of <a href="https://stackoverflow.com/users/31676/paul">Paul</a>'s code, which now should be easier for someone to help get this into a radial cluster instead of this current cluster shape</p>
  
  <p><img src="https://i.stack.imgur.com/il4wk.png" alt="right structure, wrong display - needs to be a radial cluster"></p>
  
  <pre><code>import scipy
  import pylab
  import scipy.cluster.hierarchy as sch
  
  def fix_verts(ax, orient=1):
      for coll in ax.collections:
          for pth in coll.get_paths():
              vert = pth.vertices
              vert[1:3,orient] = scipy.average(vert[1:3,orient]) 
  
  # Generate random features and distance matrix.
  x = scipy.rand(40)
  D = scipy.zeros([40,40])
  for i in range(40):
      for j in range(40):
          D[i,j] = abs(x[i] - x[j])
  
  fig = pylab.figure(figsize=(8,8))
  
  # Compute and plot the dendrogram.
  ax2 = fig.add_axes([0.3,0.71,0.6,0.2])
  Y = sch.linkage(D, method='single')
  Z2 = sch.dendrogram(Y)
  ax2.set_xticks([])
  ax2.set_yticks([])
  
  fix_verts(ax2,0)
  fig.savefig('test.png')
  </code></pre>
  
  <p>But instead of a tree-like structure, I need a radial cluster like the following diagrams.</p>
  
  <p><img src="https://i.stack.imgur.com/kELFM.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/6vZH3.gif" alt="radial cluster 1"></p>