Circos プロット
最後に、ネットワークの Circos プロットを作成します!
この演習はコースの一部です
Pythonで学ぶネットワーク分析入門
演習の手順
- ネットワークの Circos プロットを作成します。GitHub ユーザーを次数で並べ替え、
'grouping'キーでグループ分けと色分けを行います。次の手順で進めます。data=Trueを指定して、メタデータを含めてGのすべてのノードを反復処理します。- ループの各イテレーションで、
nx.degree()を使って各ノードnの次数を計算し、その'degree'属性を設定します。 - グラフ
Gに加えて 3 つのパラメータを指定してcircosプロットcを作成します。sort_by引数は'degree'、group_byとnode_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()