Circos 플롯
마지막으로, 네트워크의 Circos 플롯을 만들어 보겠습니다!
이 연습은 강의의 일부입니다
Python으로 시작하는 네트워크 분석
연습 안내
- 네트워크의 Circos 플롯을 만들되, 이번에도 GitHub 사용자를 degree 기준으로 정렬하고,
'grouping'키로 그룹화 및 색상 지정하세요. 다음을 수행합니다:data=True를 지정해 메타데이터를 포함하여G의 모든 노드를 순회하세요.- 루프의 각 반복에서
nx.degree()로 각 노드n의 degree를 계산하고 해당'degree'속성을 설정하세요. - 그래프
G외에 세 개의 매개변수를 지정하여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()