Circos 圖
最後,來為這個網路繪製一張 Circos 圖吧!
本練習屬於課程
Python 網路分析入門
練習說明
- 為此網路繪製一張 Circos 圖;GitHub 使用者需依 degree 排序,並依其
'grouping'鍵分組與著色。請依下列步驟進行:- 遍歷
G的所有節點並包含中繼資料(指定data=True)。 - 在每次迭代中,使用
nx.degree()計算每個節點n的 degree,並設定其'degree'屬性。 - 建立
circos圖物件c,在圖G之外再指定三個參數: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()