[英]Make circular Graph instead of the line Graph in Networkx
可以说我有以下情况:
import matplotlib.pyplot as plt
import networkx as nx
import pandas as pd
d = {'label': [1, 2, 3, 4, 5], 'size': [10, 8, 6, 4, 2], 'dist': [0, 2, 4, 6, 8]}
df = pd.DataFrame(data=d)
df
G = nx.Graph()
for _, row in df.iterrows():
G.add_node(row['label'], pos=(row['dist'], 0), size=row['size'])
biggest_node = 1
for node in G.nodes:
if node != biggest_node:
G.add_edge(biggest_node, node)
nx.draw(G,
pos={node: attrs['pos'] for node, attrs in G.nodes.items()},
node_size=[node['size'] * 100 for node in G.nodes.values()],
with_labels=True
)
plt.show()
这个例子来自我之前关于同一问题的问题的答案。
我现在想要做的是获得一个类似的图表,但我希望节点在圆周上对齐而不是直线。 rest保持不变,有什么办法吗? 很明显,一个人可以得到那个。 离原点最远的点将在相反的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.