-
Notifications
You must be signed in to change notification settings - Fork 6
/
plot.py
executable file
·55 lines (47 loc) · 1.49 KB
/
plot.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
#!/usr/bin/env python3
import csv
import sys
from dateutil import parser # pip install python-dateutil
from matplotlib.pyplot import clf, legend, plot, savefig, show, title
PLOTS = [
('Website Metrics', ['Homepage Views', 'Installation Views', 'Tutorials Views']),
('Website by Country', ['US Views', 'China Views', 'Germany Views', 'Japan Views']),
('ROS Answers Website Metrics', ['questions hits', 'ask hits']),
('Communication Platforms', ['users subscribers', 'wiki.ros.org users', 'answers users', 'discourse users']),
('Wiki Stats', ['wiki pages', 'wiki page views']),
('ROS Answers Stats', ['Questions', 'Answered Questions']),
]
SINGLE_PLOTS = ['Total Downloads', 'Unique IPs', 'Papers Citing']
D = csv.DictReader(open('data/aggregated.csv'))
ROWS = {}
for row in D:
a = []
for key in D.fieldnames[1:]:
try:
a.append(float(row[key]))
except ValueError:
a.append(None)
ROWS[row['']] = a
save_to_file = '-s' in sys.argv
c = 0
dates = [parser.parse(d) for d in D.fieldnames[1:]]
for name, keys in PLOTS:
for key in keys:
plot(dates, ROWS[key], 'o-', label=key)
legend(loc=0)
title(name)
if save_to_file:
savefig('%02d - %s.png' % (c, name))
c += 1
clf()
else:
show()
for key in SINGLE_PLOTS:
plot(dates, ROWS[key], 'o-', label=key)
title(key)
if save_to_file:
savefig('%02d - %s.png' % (c, key))
c += 1
clf()
else:
show()