Circos plot
Finally, you're going to make a Circos plot of the network!
This exercise is part of the course
Introduction to Network Analysis in Python
Exercise instructions
- 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 specifyingdata=True
). - In each iteration of the loop, calculate the degree of each node
n
withnx.degree()
and set its'degree'
attribute. - Create the
circos
plotc
by specifying three parameters in addition to the graphG
: thesort_by
argument, which is'degree'
, and thegroup_by
andnode_color_by
arguments, which are both'grouping'
. - Draw the
Circos
plot to the screen.
- Iterate over all the nodes in
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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()