-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotter.py
91 lines (65 loc) · 2.37 KB
/
plotter.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import matplotlib.pyplot as plt
def create_tier_graph(god_list: list):
labels = 'S', 'A', 'B', 'C', 'D'
tier_counts = [0, 0, 0, 0, 0]
for entry in god_list:
if entry['tier'] == 'S':
tier_counts[0] += 1
elif entry['tier'] == 'A':
tier_counts[1] += 1
elif entry['tier'] == 'B':
tier_counts[2] += 1
elif entry['tier'] == 'C':
tier_counts[3] += 1
elif entry['tier'] == 'D':
tier_counts[4] += 1
fig1, ax1 = plt.subplots()
ax1.pie(tier_counts, labels=labels, autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal')
plt.savefig('output/tier.png')
def create_source_graph(god_list: list):
labels = 'nhentai.net', 'imgur.com', 'Other'
source_counts = [0, 0, 0]
for entry in god_list:
if 'nhentai.net' in entry['link']:
source_counts[0] += 1
elif 'imgur.com' in entry['link']:
source_counts[1] += 1
else:
source_counts[2] += 1
fig1, ax1 = plt.subplots()
ax1.pie(source_counts, labels=labels, autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal')
plt.savefig('output/source.png')
def create_tag_graph(god_list: list):
tags_and_counts = {}
for entry in god_list:
for tag in entry['tags']:
if tag in tags_and_counts.keys():
tags_and_counts[tag] += 1
else:
tags_and_counts[tag] = 1
tags_and_counts = sorted(tags_and_counts.values(), reverse=True)
fig1, ax1 = plt.subplots()
names = list(tags_and_counts.keys())
values = list(tags_and_counts.values())
ax1.bar(names, values)
plt.savefig('output/tags.png')
def create_parody_graph(god_list: list):
parodies_and_counts = {'Original': 0}
for entry in god_list:
if entry['parody'] == 'None':
parodies_and_counts['Original'] += 1
elif entry['parody'] in parodies_and_counts:
parodies_and_counts[entry['parody']] += 1
else:
parodies_and_counts[entry['parody']] = 1
fig1, ax1 = plt.subplots()
labels = list(parodies_and_counts.keys())
values = list(parodies_and_counts.values())
ax1.pie(values, labels=labels, autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal')
plt.savefig('output/parodies.png')