forked from sd17spring/InteractiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake_figure.py
More file actions
39 lines (27 loc) · 923 Bytes
/
make_figure.py
File metadata and controls
39 lines (27 loc) · 923 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
29
30
31
32
33
34
35
36
37
38
39
from plotly.graph_objs import Scatter, Figure, Layout
from compute_distances import compute_distances()
distances = compute_distances()
def make_figure():
width = 1200
height = 800
mid = int(height/2)
# --------- DRAWING LINES AND POINTS--------------------------------
ylist = []
xlist = []
for key in distances:
dist = distances[key] # scale down distances
point1 = mid - 0.5*dist # calculates points for person 1
point2 = mid + 0.5*dist # calculates points for person 2
year = int(key[0:4])
month = int(key[5:7])
day = int(key[8:10])
t = datetime.date(year, month, day)
x = (t - datetime.date(1990, 1, 1)).total_seconds()
y1 = point1
y2 = point2
ylist.append(y1)
xlist.append(x)
plot([Scatter(x=xlist, y=ylist)])
if dist == 0:
meetings.append((key, mid))
make_figure()