#same identical code as above, but here we change the layout algorithm to use Graphviz's "fdp" layout engine, which uses a global energy minimization function and tends to yield insightful clustering with nodes separated enough to be readable import math import graphviz import pydot g = nx . Graph () for r in results . values : g . add_edge ( r [ 0 ], r [ 1 ], weight = r [ 2 ] / 10 ) #set up with a white background and no grid lines plt . figure ( figsize = ( 30 , 20 )); plt . title ( 'GDELT Project: People most associated in global news with Greek Prime Minister Alexis Tsipras March 2-3, 2015' , y = 0.97 , fontsize = 20 , fontweight = 'bold' ) cf = plt . gcf () ax = cf . gca () ax . set_axis_off () gmax = max ( nx . connected_component_subgraphs ( g ), key = len ) d = nx . degree ( gmax ) b = nx . betweenness_centrality ( gmax ) . items () #use graphviz's engines - options for "prog" are: dot, neato, fdp, twopi, circo pos = nx . graphviz_layout ( gmax , prog = 'fdp' ) nx . draw_networkx_edges ( gmax , pos , nodelist = [ v [ 0 ] for v in b ], node_size = [ d [ v [ 0 ]] * 100 for v in b ], with_labels = False , alpha = 0.3 , node_color = [ math . log ( 1 + v [ 1 ] * 1000 ) for v in b ], cmap = plt . cm . Blues , width = [ gmax [ u ][ v ][ 'weight' ] for u , v in gmax . edges ()]) nx . draw_networkx_nodes ( gmax , pos , nodelist = [ v [ 0 ] for v in b ], node_size = [ d [ v [ 0 ]] * 100 for v in b ], with_labels = True , alpha = 0.9 , node_color = [ math . log ( 1 + v [ 1 ] * 1000 ) for v in b ], cmap = plt . cm . Blues , width = [ gmax [ u ][ v ][ 'weight' ] for u , v in gmax . edges ()]) nx . draw_networkx_labels ( gmax , pos , nodelist = [ v [ 0 ] for v in b ], node_size = [ d [ v [ 0 ]] * 100 for v in b ], with_labels = True , node_color = [ math . log ( 1 + v [ 1 ] * 1000 ) for v in b ], cmap = plt . cm . Blues , width = [ gmax [ u ][ v ][ 'weight' ] for u , v in gmax . edges ()]) #add a final empty quote at the end to prevent IPython from outputting the full list of labels at the end ''