-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_utils.py
55 lines (42 loc) · 1.25 KB
/
plot_utils.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
import itertools
import math
import numpy as np
DPI = 150
SIZE_INCHES = (1920 / DPI, 1080 / DPI)
def coprime(a, b):
return math.gcd(a, b) == 1
def find_coprime(n):
for a in range(3, math.ceil(math.sqrt(n))):
if coprime(a, n):
return a
return 3
def nth_steps(items):
"""
>>> nth_steps('ABCDEFG')
['A', 'F', 'D', 'B', 'G', 'E']
"""
n = find_coprime(len(items))
return list(itertools.islice(
itertools.islice(
itertools.cycle(items),
None,
None,
n,
),
len(items),
))
def get_teams_with_hues(comp, final_match_num, tlas, highlight):
# Add 1 to prevent overlap when only showing a small number of teams; due to
# the circular nature of colour wheels.
hues = np.linspace(0., 1., len(comp.teams.keys()) + 1)
# Rotate around the space to find colours we like. Manually chosen number
# based on eyeballing the resulting plots. Value is mod-N, for N being the
# coprime root in `find_coprime`.
for _ in range(1):
hues = nth_steps(hues)
return [
(team, hue)
for team, hue in zip(comp.teams.values(), hues)
if team.tla in tlas
if team.is_still_around(final_match_num)
]