forked from AdriaanRol/AutoDepGraph
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvisualization.py
More file actions
28 lines (22 loc) · 985 Bytes
/
visualization.py
File metadata and controls
28 lines (22 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import networkx as nx
# Colormap used to map states to node colors
state_cmap = { # 'unknown': '#7f7f7f', # middle gray
'unknown': '#D3D3D3', # light gray
'active': '#1f77b4', # muted blue
'good': '#2ca02c', # cooked asparagus green
'needs calibration': '#ff7f0e', # safety orange
'bad': '#d62728', # brick red
}
# symbol map
pyqtgraph_symbol_map = {'normal': 'o', # a circle
'manual_cal': 'h', } # a hexagon
dot_type_symbol_map = {'normal': 'circle', # a circle
'manual_cal': 'hexagon', } # a hexagon
def draw_graph_svg(nxG, filename: str):
"""
Creates an svg using graphviz.
If the file is saved to "autodepgraph/svg_viewer/adg_graph.svg" the
realtime svg viewer can render it.
"""
gvG = nx.nx_agraph.to_agraph(nxG)
gvG.draw(filename, prog='dot')