How do I create a radial cluster like the following code-example in Python?
Question: I've found several examples on how to create these exact hierarchies (at least
I believe they are) like the following here
[stackoverflow.com/questions/2982929/](http://stackoverflow.com/questions/2982929/plotting-
results-of-hierarchical-clustering-ontop-of-a-matrix-of-data-in-python) which
work great, and almost perform what I'm looking for.

[EDIT]Here's a simplified version of
[Paul](http://stackoverflow.com/users/31676/paul)'s code, which now should be
easier for someone to help get this into a radial cluster instead of this
current cluster shape

![right structure, wrong display - needs to be a radial
cluster](http://i.stack.imgur.com/il4wk.png)

    
    
    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')
    

But instead of a tree-like structure, I need a radial cluster like the
following diagrams.

![enter image description here](http://i.stack.imgur.com/kELFM.png) ![radial
cluster 1](http://i.stack.imgur.com/6vZH3.gif)


Answer: I believe you can do this using the `networkx` package in conjunction with
`matplotlib`. Check out the following example from the `networkx` gallery:

<http://networkx.lanl.gov/examples/drawing/circular_tree.html>

In general `networkx` has a number of really nice graph analysis and plotting
methods

![enter image description here](http://i.stack.imgur.com/aSdw1.png)

