【发布时间】:2020-10-10 11:42:31
【问题描述】:
我有一个使用 networkx 创建的网络。
我想查看网络中所有节点相对于同一网络中特定节点的分布。
我创建了两个节点度数如下:
df = df.T.corr(method="spearman")
edges = df.stack().reset_index()
edges.columns = ['var_1','var_2','correlation']
edges = edges.loc[ (edges['correlation'] < -0.6) | (edges['correlation'] > 0.6) & (edges['var_1'] != edges['var_2']) ].copy()
#create undirected graph with weights corresponding to the correlation magnitude
G0 = nx.from_pandas_edgelist(edges, 'var_1', 'var_2', edge_attr=['correlation'])
print(nx.info(G0))
# =============================================================================
degrees = [val for (node, val) in G0.degree()]
degrees2 = [val for (node, val) in G0.degree(['Aureobasidium', 'Cladosporium', 'Alternaria',
'Filobasidium', 'Vishniacozyma',
'Sporobolomyces', 'Sphingomonas',
'Methylobacterium'])]
如何在简单的条形图上表示节点度数(两个条形图相邻) 当Y轴是每个度数,X轴是度数时
我找到了这个代码:https://networkx.github.io/documentation/stable/auto_examples/drawing/plot_degree_histogram.html 这就是我想要的没有小型网络。
虽然我希望酒吧彼此相邻
任何停顿都会被磨平!天呐!
【问题讨论】:
-
您能否编辑您的问题并添加您用于条形图的确切代码?
标签: python matplotlib networkx