Given an interger of N values, return a cyclic list
of size N with repeated 20 altair standards colors.
PARAMETER |
DESCRIPTION |
N |
TYPE:
int
|
RETURNS |
DESCRIPTION |
List[str]
|
|
Source code in eds_scikit/plot/altair_utils.py
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 | def generate_cyclic_colors(N: int) -> List[str]:
"""Given an interger of N values, return a cyclic list
of size N with repeated 20 altair standards colors.
Parameters
----------
N : int
Returns
-------
List[str]
"""
category20_colors = [
"#1f77b4",
"#ff7f0e",
"#2ca02c",
"#d62728",
"#9467bd",
"#8c564b",
"#e377c2",
"#7f7f7f",
"#bcbd22",
"#17becf",
"#aec7e8",
"#ffbb78",
"#98df8a",
"#ff9896",
"#c5b0d5",
"#c49c94",
"#f7b6d2",
"#c7c7c7",
"#dbdb8d",
"#9edae5",
]
num_colors = len(category20_colors)
return [category20_colors[i % num_colors] for i in range(N)]
|