Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,17 +57,22 @@ def create_network_graph(topic_results, num_words=10):
|
|
| 57 |
return G
|
| 58 |
|
| 59 |
def plot_network_graph(G):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
plt.figure(figsize=(12, 8))
|
| 61 |
pos = nx.spring_layout(G, k=0.5, iterations=50)
|
| 62 |
|
| 63 |
node_colors = [G.nodes[node]['color'] for node in G.nodes()]
|
| 64 |
|
| 65 |
nx.draw(G, pos, node_color=node_colors, with_labels=True, node_size=3000, font_size=8,
|
| 66 |
-
font_weight='bold', edge_color='gray', width=0.5)
|
| 67 |
|
| 68 |
for node, (x, y) in pos.items():
|
| 69 |
plt.text(x, y, node, fontsize=8, fontweight='bold', ha='center', va='center',
|
| 70 |
-
bbox=dict(facecolor='white', edgecolor='none', alpha=0.7, pad=0.5))
|
| 71 |
|
| 72 |
plt.title("Topic Word Network", fontsize=16)
|
| 73 |
plt.axis('off')
|
|
|
|
| 57 |
return G
|
| 58 |
|
| 59 |
def plot_network_graph(G):
|
| 60 |
+
# 한국어 폰트 설정
|
| 61 |
+
font_path = "/usr/share/fonts/truetype/nanum/NanumGothic.ttf" # 설치된 폰트의 경로
|
| 62 |
+
font_prop = fm.FontProperties(fname=font_path)
|
| 63 |
+
plt.rc('font', family=font_prop.get_name())
|
| 64 |
+
|
| 65 |
plt.figure(figsize=(12, 8))
|
| 66 |
pos = nx.spring_layout(G, k=0.5, iterations=50)
|
| 67 |
|
| 68 |
node_colors = [G.nodes[node]['color'] for node in G.nodes()]
|
| 69 |
|
| 70 |
nx.draw(G, pos, node_color=node_colors, with_labels=True, node_size=3000, font_size=8,
|
| 71 |
+
font_weight='bold', edge_color='gray', width=0.5, font_family=font_prop.get_name())
|
| 72 |
|
| 73 |
for node, (x, y) in pos.items():
|
| 74 |
plt.text(x, y, node, fontsize=8, fontweight='bold', ha='center', va='center',
|
| 75 |
+
bbox=dict(facecolor='white', edgecolor='none', alpha=0.7, pad=0.5), fontproperties=font_prop)
|
| 76 |
|
| 77 |
plt.title("Topic Word Network", fontsize=16)
|
| 78 |
plt.axis('off')
|