开始使用免费开始使用

Circos 图

最后,您将为该网络绘制一幅 Circos 图!

本练习是课程的一部分

Python 网络分析入门

查看课程

练习说明

  • 为该网络绘制一幅 Circos 图。再次按节点的度数对 GitHub 用户排序,并按其 'grouping' 键进行分组和着色。具体步骤:
    • 遍历 G 中包含元数据的所有节点(指定 data=True)。
    • 在循环的每次迭代中,使用 nx.degree() 计算每个节点 n 的度,并设置其 'degree' 属性。
    • 通过在图 G 之外再指定 3 个参数来创建 circos 图对象 csort_by(取值为 'degree')、group_bynode_color_by(二者均取值为 'grouping')。
    • Circos 图绘制到屏幕上。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import necessary modules
from nxviz import circos
import matplotlib.pyplot as plt

# Iterate over all the nodes, including the metadata
for n, d in ____:

    # Calculate the degree of each node: G.node[n]['degree']
    ____ = ____

# Create the Circos plot: c
c = ____

# Draw the Circos plot to the screen
____
plt.show()
编辑并运行代码