Spaces:
Sleeping
Sleeping
Nu Appleblossom
commited on
Commit
•
ec3fff6
1
Parent(s):
ae9cccb
switching from graphviz to networkx
Browse files
app.py
CHANGED
@@ -19,6 +19,7 @@ from PIL import Image, ImageDraw, ImageFont
|
|
19 |
from io import BytesIO
|
20 |
import functools
|
21 |
import logging
|
|
|
22 |
|
23 |
|
24 |
# Set up custom logger
|
@@ -344,14 +345,12 @@ def create_tree_diagram(data, config, max_weight, min_weight, trim_cutoff=0):
|
|
344 |
labels = nx.get_node_attributes(G, 'label')
|
345 |
nx.draw(G, pos, labels=labels, with_labels=True, node_size=5000, node_color="lightblue", font_size=10, font_weight="bold", edge_color="gray", arrows=False)
|
346 |
|
347 |
-
# Save the image to a
|
348 |
-
|
349 |
-
plt.savefig(
|
350 |
plt.close()
|
351 |
-
output.seek(0)
|
352 |
-
|
353 |
-
return output
|
354 |
|
|
|
355 |
|
356 |
|
357 |
|
|
|
19 |
from io import BytesIO
|
20 |
import functools
|
21 |
import logging
|
22 |
+
import tempfile
|
23 |
|
24 |
|
25 |
# Set up custom logger
|
|
|
345 |
labels = nx.get_node_attributes(G, 'label')
|
346 |
nx.draw(G, pos, labels=labels, with_labels=True, node_size=5000, node_color="lightblue", font_size=10, font_weight="bold", edge_color="gray", arrows=False)
|
347 |
|
348 |
+
# Save the image to a temporary file
|
349 |
+
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
|
350 |
+
plt.savefig(temp_file.name)
|
351 |
plt.close()
|
|
|
|
|
|
|
352 |
|
353 |
+
return temp_file.name
|
354 |
|
355 |
|
356 |
|