Commit aefeb43f authored by Alberts S's avatar Alberts S
Browse files

Visualizer: translate names of targets when using matplotlib

parent e959a277
......@@ -159,13 +159,16 @@ class Visualizer(CapybaraNetty):
async def draw_graph_networkx(self, G, output_base):
# Matplotlib + NetworkX
pos = nx.fruchterman_reingold_layout(G, 5)
fig = plt.figure(1, figsize=(60, 20), dpi=120)
fig = plt.figure(1, figsize=(20, 10), dpi=120)
labels = nx.get_edge_attributes(G, "weight")
edge_labels = nx.get_edge_attributes(G, "weight")
edge_colors = nx.get_edge_attributes(G, "color").values()
node_labels = {node_name: self.translate_target_name(node_name) for node_name in G.nodes}
node_colors = ["red" if node in self.external_targets_for_optimizations else "green" for node in G]
nx.draw_networkx_edge_labels(G, pos, edge_labels=labels, label_pos=0.5)
nx.draw(G, pos, with_labels=True, edge_color=edge_colors, node_size=100, node_color=node_colors)
nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels, label_pos=0.5)
G, pos, with_labels=True, labels=node_labels, edge_color=edge_colors, node_size=100, node_color=node_colors
output_name = f"{output_base}_networkx.png""Writing {output_name}")
plt.savefig(output_name, bbox_inches="tight")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment