NetworkX library 에 대해 리뷰할 예정이다.
1. draw_networkx
draw_networkx — NetworkX 3.1rc1.dev0 documentation
draw_networkx draw_networkx(G, pos=None, arrows=None, with_labels=True, **kwds)[source] Draw the graph G using Matplotlib. Draw the graph with Matplotlib with options for node positions, labeling, titles, and many other drawing features. See draw() for sim
networkx.org
2. Networkx graphs from source-target dataframes
NetworkX Graphs from Source-Target DataFrame
This page is based on a Jupyter/IPython Notebook: download the original .ipynb Making networkx graphs from source-target DataFrames Imports/setup Let’s just get all of this out of the way up top. %matplotlib inline import pandas as pd import networkx as
jonathansoma.com

Reference
How to determine specific color and size of chosen nodes in Networkx graph plot
I have the following code #!/usr/bin/python import sys import networkx as nx import matplotlib.pyplot as plt G = nx.Graph(); G.add_node('A') G.add_node('B') G.add_node('C') G.add_node('D') G.
stackoverflow.com
Before
output_graph
output_graph_matrix = nx.adjacency_matrix(output_graph).todense()
nx.draw_networkx(output_graph, font_size=10, font_color='r')
sns.heatmap(output_graph_matrix)

After
output_graph
output_graph_matrix = nx.adjacency_matrix(output_graph).todense()
nx.draw_spring(output_graph, nodelist=sorted(output_graph.nodes()), font_size=20, width=2,
node_size=[100, 100, 200, 300,200, 200, 200,200,200,200,200],
node_color=['g','r','b','g','r','b','g','r','b','g','r']
)

'Data Science & Analytics' 카테고리의 다른 글
빅데이터분석기사시험 공부 (0) | 2024.06.18 |
---|---|
[Databricks] The Big Book of Data Science Use cases (0) | 2024.04.25 |
[Coursera] Google Data Analytics, Advanced Data analytics 인증서 내용 비교 (1) | 2023.04.22 |
[Data Visualization] Plot area color in python (0) | 2023.02.12 |
[리뷰] 데이터분석전문가 가이드북 정리 (0) | 2022.01.11 |