histlearn commited on
Commit
8a2ba4f
·
verified ·
1 Parent(s): f274747

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -48,14 +48,21 @@ def run_query_and_visualize(qtext, jsonld_url):
48
  G.add_edge(str(s), str(o), label=str(p).split('/')[-1])
49
 
50
  # Desenha o gráfico usando NetworkX e Matplotlib
51
- pos = nx.spring_layout(G, k=0.8)
52
- plt.figure(figsize=(15, 10))
53
-
54
- nodes = nx.draw_networkx_nodes(G, pos, node_size=5000, node_color="#87CEEB", edgecolors="black")
55
- edges = nx.draw_networkx_edges(G, pos, width=2, edge_color="gray", alpha=0.6)
56
- node_labels = nx.draw_networkx_labels(G, pos, font_size=12, font_color="black")
57
- edge_labels = nx.draw_networkx_edge_labels(G, pos, edge_labels=nx.get_edge_attributes(G, 'label'), font_color="red", font_size=10)
58
-
 
 
 
 
 
 
 
59
  plt.title("Resultado da Consulta SPARQL", size=15)
60
  plt.axis('off')
61
 
 
48
  G.add_edge(str(s), str(o), label=str(p).split('/')[-1])
49
 
50
  # Desenha o gráfico usando NetworkX e Matplotlib
51
+ pos = {
52
+ "Adem": (0, 0.6),
53
+ "Adem-geo": (-0.4, -0.3),
54
+ "Adem-obra": (0.4, -0.1)
55
+ }
56
+
57
+ plt.figure(figsize=(10, 8))
58
+ nx.draw_networkx_nodes(G, pos, node_size=3000, node_color="skyblue", alpha=0.9)
59
+ nx.draw_networkx_edges(G, pos, width=2, alpha=0.5, edge_color='gray')
60
+ nx.draw_networkx_labels(G, pos, labels=nx.get_node_attributes(G, 'label'), font_size=9, font_color="black")
61
+ nx.draw_networkx_edge_labels(G, pos, edge_labels=nx.get_edge_attributes(G, 'label'), font_size=9, font_color="red")
62
+
63
+ plt.xlim(-1, 1)
64
+ plt.ylim(-1, 1)
65
+
66
  plt.title("Resultado da Consulta SPARQL", size=15)
67
  plt.axis('off')
68