forked from UT-OSPO/institutional-innovation-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub-data-visualizer.py
76 lines (53 loc) · 1.89 KB
/
github-data-visualizer.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
import matplotlib.pyplot as plt
import csv
import json
with open(".env") as envfile:
config = json.loads(envfile.read())
languagedata = []
licensedata = []
starcountdata = []
watchercountdata = []
forkcountdata = []
createdatdata = []
updatedatdata = []
with open(config["githubrepodatacsvpathforvisualization"], "r") as repodatacsv:
repodata = csv.reader(repodatacsv)
for row in repodata:
primarylanguage = row[10]
license = row[15]
starcount = row[8]
watchercount = row[9]
forkcount = row[11]
datecreated = row[5]
dateupdated = row[6]
yearssincecreated = ""
yearssinceupdated = ""
languagedata.append(primarylanguage)
licensedata.append(license)
starcountdata.append(starcount)
watchercountdata.append(watchercount)
forkcountdata.append(forkcount)
createdatdata.append(datecreated)
updatedatdata.append(dateupdated)
def createpiechart(dataset, otherthreshold, title):
datalabels = []
datacounts = []
dataothercount = 0
for datapoint in set(dataset):
if dataset.count(datapoint) < otherthreshold:
dataothercount += dataset.count(datapoint)
else:
if datapoint == "":
datalabels.append("None")
else:
datalabels.append(datapoint.strip())
datacounts.append(dataset.count(datapoint))
fig, ax = plt.subplots()
ax.set_title = title
plt.suptitle(title)
notex, notey = .01, .01
fig.text(notex, notey,'* values with counts under ' + str(otherthreshold) + ' merged into \'other\' category', transform=fig.transFigure)
ax.pie(datacounts, labels=datalabels)
plt.show()
createpiechart(licensedata, 5,"Licenses Assigned to Affiliated GitHub Repositories")
createpiechart(languagedata, 20, "Primary Language Used in Affiliated GitHub Repositories")