MulaiMulai sekarang secara gratis

Circos plot

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

Latihan ini adalah bagian dari kursus

Introduction to Network Analysis in Python

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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()
Edit dan Jalankan Kode