-
Notifications
You must be signed in to change notification settings - Fork 0
/
charter.py
50 lines (43 loc) · 1.17 KB
/
charter.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
import json
import datetime
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
colors = [
"black",
"xkcd:dark red",
"red",
"orange",
"yellow",
"xkcd:lime",
"green",
"xkcd:dark green",
"xkcd:cyan",
"xkcd:blue",
"xkcd:dark blue",
]
def do_chart():
with open("wanikani_perf.json") as d:
data = json.load(d)
fig = plt.figure(figsize=[8, 13])
for i, t in enumerate(["radical", "kanji", "vocabulary"]):
ax = fig.add_subplot(311 + i)
ax.set_title(t.capitalize())
labels = []
for x in range(1, 10):
f = []
s = []
for k, v in data.items():
f.append(datetime.datetime.fromisoformat(k))
try:
s.append(v[t][f"{x}"])
except KeyError:
s.append(0)
if not any(a != 0 for a in s):
continue
ax.plot(f, s, color=colors[x])
labels.append(str(x))
ax.legend(labels, loc="upper left", ncol=4)
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y\n%m-%d'))
plt.show()
if __name__ == '__main__':
do_chart()