Is there a way to adjust positions of nodes in Networkx plot ? For example, as shown below, I am trying to colour communities of friends in one zone. However, the dark blue and the dark green regions seem to overlap (although they form their own individual community)?
A = np.array(input_data) #input adjacency graph
for x in range(1,node+1):
for y in range(1,node+1):
if A[x][y] == 1:
G.add_edge(x, y, color='gray', weight=1) #W[x][y]
Z = np.array(node) # input of nodes
nodeZone = Z[:,0]
color_map = []
node_shape = []
for node in G:
print(node)
if nodeZone[node-1]== 1:
color_map.append('aqua')
# node_shape.append('\'o\',')
elif nodeZone[node-1]== 2:
color_map.append('lawngreen')
# node_shape.append('\'s\',')
elif nodeZone[node-1]== 3:
color_map.append('forestgreen')
# node_shape.append('\'v\',')
else:
color_map.append('gray')
pos = nx.kamada_kawai_layout(G)
edges = G.edges()
colors = [G[u][v]['color'] for u,v in edges]
weights = [G[u][v]['weight'] for u,v in edges]
nx.draw(G, dim=2, pos=pos, edges=edges, edge_color=colors, width=weights,node_size=50,node_color=color_map, with_labels=True,font_size=6)
plt.show()