def plot_weighted_graph(G, dim = 'xy', node_colors = None, title='graph'):
    """docstring for plot_weighted_graph"""
    pth, _ = os.path.split(__file__)
    aal_txt = os.path.join(pth, 'tests', 'data', 'aal.txt')
    aal_coords = os.path.join(pth, 'tests', 'data', 'aal_coords')
    aal_90, labels = parse_aal(aal_coords, aal_txt, dim = dim)
    if node_colors is None:
        nxplot.draw_graph(G, layout = aal_90, labels = labels)
    else:
        nxplot.draw_graph(G, layout = aal_90, labels = labels,
                          node_colors = node_colors,
                          title = title)
    plt.show()
Beispiel #2
0
colors = ['y' for _ in head] + ['r' for _ in tail]

mat = util.symm_rand_arr(size)
mat = 2 * mat - 1  # map values to [-1,1] range
util.fill_diagonal(mat, 0)  # diag==0 so we don't get self-links

layout = nx.circular_layout

G = util.mat2graph(mat, threshold=th1, threshold2=th2)

pfig = nxplot.draw_graph(
    G,
    labels=labels,
    node_colors=colors,
    layout=layout,
    title=layout.func_name,
    #edge_cmap=cm.PuOr
    edge_cmap=cm.RdBu,
    #edge_cmap=cm.jet,
    colorbar=True,
)

if 0:
    layout_funcs = [
        nx.circular_layout,
        nx.fruchterman_reingold_layout,
        nx.graphviz_layout,
        nx.pydot_layout,
        nx.pygraphviz_layout,
        nx.random_layout,
        nx.shell_layout,
Beispiel #3
0
th2 = 0.9
th1 = -th2

# Split the node list in half, and use two colors for each group
split = size / 2
nodes = range(size)
head, tail = nodes[:split], nodes[split:]
labels = ["%s%s" % (chr(i), chr(i + 32)) for i in range(65, 65 + size)]
# labels = map(str,nodes)
colors = ["y" for _ in head] + ["r" for _ in tail]

mat = util.symm_rand_arr(size)
mat = 2 * mat - 1  # map values to [-1,1] range
util.fill_diagonal(mat, 0)  # diag==0 so we don't get self-links
pfig, G = nxplot.draw_graph(
    mat,
    threshold=th1,
    threshold2=th2,
    labels=labels,
    colors=colors,
    edge_cmap=cm.PuOr
    # edge_cmap=cm.RdBu,
    # edge_cmap=cm.jet,
)

# dmat = np.random.rand(size,size)
# nxplot.draw_graph(mat,dmat=dmat)
# print 'Mat:\n',mat

plt.show()
#labels = map(str,nodes)
colors = ['y' for _ in head] + ['r' for _ in tail]

mat = util.symm_rand_arr(size)
mat = 2*mat-1  # map values to [-1,1] range
util.fill_diagonal(mat,0)  # diag==0 so we don't get self-links

layout = nx.circular_layout

G = util.mat2graph(mat, threshold=th1,threshold2=th2)

pfig = nxplot.draw_graph(G,
                         labels=labels,
                         node_colors=colors,
                         layout = layout,
                         title = layout.func_name,
                         #edge_cmap=cm.PuOr
                         edge_cmap=cm.RdBu,
                         #edge_cmap=cm.jet,
                         colorbar=True,
                         )

if 0:
    layout_funcs = [ nx.circular_layout,
                     nx.fruchterman_reingold_layout,
                     nx.graphviz_layout,
                     nx.pydot_layout,
                     nx.pygraphviz_layout,
                     nx.random_layout,
                     nx.shell_layout,
                     nx.spectral_layout,
                     nx.spring_layout,
Beispiel #5
0
size = 11
th2 = 0.9
th1 = -th2

# Split the node list in half, and use two colors for each group
split = size / 2
nodes = range(size)
head, tail = nodes[:split], nodes[split:]
labels = ['%s%s' % (chr(i), chr(i + 32)) for i in range(65, 65 + size)]
#labels = map(str,nodes)
colors = ['y' for _ in head] + ['r' for _ in tail]

mat = util.symm_rand_arr(size)
mat = 2 * mat - 1  # map values to [-1,1] range
util.fill_diagonal(mat, 0)  # diag==0 so we don't get self-links
pfig, G = nxplot.draw_graph(mat,
                            threshold=th1,
                            threshold2=th2,
                            labels=labels,
                            colors=colors,
                            edge_cmap=cm.PuOr
                            #edge_cmap=cm.RdBu,
                            #edge_cmap=cm.jet,
                            )

#dmat = np.random.rand(size,size)
#nxplot.draw_graph(mat,dmat=dmat)
#print 'Mat:\n',mat

plt.show()