使用 Arc 圖視覺化
延續你對 nxviz API 的學習,現在試著為這個網路繪製一個 Arc 圖。你將在這裡使用兩個關鍵字參數 sort_by='keyX' 與 node_color_by='keyX',藉由指定節點中繼資料字典裡的某個鍵,來決定節點的著色與排序。
matplotlib.pyplot 已替你匯入為 plt。
本練習屬於課程
Python 網路分析入門
練習說明
- 從
nxviz匯入arc。 - 建立
T的未自訂 Arc 圖。為此,僅使用arc()函式並以T作為引數。 - 再建立一個
T的 Arc 圖,並依'category'這個關鍵詞來排序與著色節點。你需要指定sort_by與node_color_by參數。對於兩個圖,都要將它們畫到螢幕並用plt.show()顯示。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import necessary modules
import matplotlib.pyplot as plt
____
# Create the un-customized Arc plot: a
a = ____
# Display the plot
plt.show()
# Create the customized Arc plot: a2
a2 = ____
# Display the plot
plt.show()