开始使用免费开始使用

Circos plot

Finally, you're going to make a Circos plot of the network!

本练习是课程的一部分

Introduction to Network Analysis in Python

查看课程

练习说明

  • Make a Circos plot of the network, again, with GitHub users sorted by their degree, and grouped and colored by their 'grouping' key. To do this:
    • Iterate over all the nodes in G, including the metadata (by specifying data=True).
    • In each iteration of the loop, calculate the degree of each node n with nx.degree() and set its 'degree' attribute.
    • Create the circos plot c by specifying three parameters in addition to the graph G: the sort_by argument, which is 'degree', and the group_by and node_color_by arguments, which are both 'grouping'.
    • Draw the Circos plot to the screen.

交互式实操练习

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

# 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()
编辑并运行代码