-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawIndex.py
executable file
·69 lines (62 loc) · 1.52 KB
/
drawIndex.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import plotly.graph_objects as go
height = 0
nodes = []
with open("Index.csv") as f:
for i, line in enumerate(f):
if int(line.split(",")[0]) == height:
nodes.append(
(
float(line.split(",")[2]),
float(line.split(",")[3]),
float(line.split(",")[4]),
float(line.split(",")[5]),
)
)
fig = go.Figure()
# Set axes properties
fig.update_xaxes(
range=[-182, 182],
showgrid=False,
zeroline=False,
mirror=True,
# ticks="outside",
showticklabels=False,
showline=False,
linecolor="black",
)
fig.update_yaxes(
range=[-91, 91],
showgrid=False,
zeroline=False,
mirror=True,
# ticks="outside",
showticklabels=False,
showline=False,
linecolor="black",
)
perimeter = 0
# Add shapes
for n in nodes:
fig.add_trace(
go.Scatter(
mode="lines",
x=[n[0], n[0], n[2], n[2], n[0]],
y=[n[1], n[3], n[3], n[1], n[1]],
line=dict(color="black", width=0.75),
)
)
perimeter += 2 * ((n[2] - n[0]) + (n[3] - n[1]))
numNodes = len(nodes)
avgLen = perimeter / numNodes
print(
f"Total Number of Nodes: {numNodes}\nAverage Perimeter: {avgLen:.2f}\n"
)
# fig.update_shapes(dict(xref='x', yref='y', line=dict(color="black")))
fig.update_layout(
showlegend=False,
plot_bgcolor="white",
margin=dict(l=0, r=0, t=0, b=0),
height=720,
width=1440,
)
fig.write_image(file="Index.png")