2017-03-02 1 views
1

にnetworkxで円グラフ内のノードにラベルを追加するには:どのようにメソッドを使用して、円形のグラフを描いてるのpython

nx.draw_circular(G, node_color='b', edge_color='#909090', node_size=500) 

基本的に私が何をしたいのかがノードにラベルを追加することですが、私このタイプのグラフにそれらを追加する方法はありません。私が使用してみました:

nx.draw_networkx_labels(G,labels=labels,pos=nx.spring_layout(G),font_size=16)

がなく、位置のレイアウトに問題があり、それは各ノードに/次はありません。

enter image description here

答えて

1

解決済み!

G=nx.Graph() 
G.add_nodes_from(range(20)) 
e = [(0,1),(0,2)] 
G.add_edges_from(e) 

# some labels 
labels={} 

nx.draw_circular(G, node_color='y', edge_color='#909090', node_size=500,labels=labels) 

plt.axis('equal') 

enter image description here

関連する問題