Drawing graph with 1200 nodes, and all nodes overlapped with each other

807 views
Skip to first unread message

Noob

unread,
Jul 10, 2012, 9:23:59 AM7/10/12
to networkx...@googlegroups.com
Hi all,

i have a weird issue when drawing a graph with about 1200 nodes.

I intend to draw a graph with multiple node colors and node shapes, and the code responsible for drawing my graph is as follows:

    
    import matplotlib.pyplot as plt    
    import networkx as nx 
    entire_graph = nx.DiGraph()
    # graph is being build based on retweet relationships.... some code truncated....

    ns = len(entire_graph)

    plt.figure(figsize=(100,100))    
    pos=nx.spring_layout(entire_graph)
    
    nx.draw_networkx_nodes(entire_graph,pos,
                           nodelist=list_of_nodes['yellow'],
                           node_color='#FFE303',
                           node_shape='o',
                           node_size=ns,
                       alpha=0.8)
    nx.draw_networkx_nodes(entire_graph,pos,
                           nodelist=list_of_nodes['blue'],
                           node_color='#0066CC',
                           node_shape='o',
                           node_size=ns,
                       alpha=0.8)

    nx.draw_networkx_nodes(entire_graph,pos,
                           nodelist=list_of_nodes['green'],
                           node_color='#00FF00',
                           node_shape='o',
                           node_size=ns,
                       alpha=0.8)

    nx.draw_networkx_nodes(entire_graph,pos,
                           nodelist=list_of_nodes['d'],
                           node_shape='d',
                           node_size=ns,
                       alpha=0.8)
    nx.draw_networkx_nodes(entire_graph,pos,
                           nodelist=list_of_nodes['p'],
                           node_shape='p',
                           node_size=ns,
                       alpha=0.8)

    nx.draw_networkx_nodes(entire_graph,pos,
                           nodelist=list_of_nodes['h'],
                           node_shape='h',
                           node_size=ns,
                       alpha=0.8)

    nx.draw_networkx_nodes(entire_graph,pos,
                           nodelist=list_of_nodes['8'],
                           node_shape='8',
                           node_size=ns,
                       alpha=0.8)

    # edges
    nx.draw_networkx_edges(entire_graph,pos)
    edgelist = []
    for _g in entire_graph:
        for k,v in enumerate(entire_graph[_g]):
            
            t = (_g, v)
            edgelist.append(t)
            
            
    file = "spring_layout.png"
    #nx.draw_networkx_nodes(g,pos,nodelist=[g],node_size=node_size_number,node_color='r')
    
    nx.draw_networkx_edges(entire_graph,pos,
                           edgelist=edgelist,
                           width=0.8,alpha=1)
    plt.axis('off')
    plt.savefig(file)


I've tried varying the node_size and figure size, and using the spring layout i end up with a drawing
where all nodes overlap with each other. ( see spring_layout.png )

I've tried using other layout such as circular layout, i end up with a diagram looking like circular.png

Any ideas/suggestions/advise for me?  I would prefer to use the spring layout if possible,

Thanks!

circular.png
spring_layout.png

Brian Keegan

unread,
Jul 10, 2012, 9:44:05 AM7/10/12
to networkx...@googlegroups.com
With anything larger than toy networks a few dozen nodes, I would recommend exporting the data to a dedicated network visualization package like Pajek, Gephi, or Cytoscape.


--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/networkx-discuss/-/QtFgR_gE4bYJ.
To post to this group, send email to networkx...@googlegroups.com.
To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.



--
Brian C. Keegan
Ph.D. Student - Media, Technology, & Society
School of Communication, Northwestern University

Science of Networks in Communities, Laboratory for Collaborative Technology

gsal

unread,
Jul 14, 2012, 11:16:50 AM7/14/12
to networkx...@googlegroups.com
Can you just take the "pos" array and multiply it by some number?  That would increase the distance between all nodes...you may have to increase the size of the fig, but that can be done interactively in matplotlib.  Anyway, this would increase the distance between nodes without increasing the size of the nodes.
Reply all
Reply to author
Forward
0 new messages