author | wenzelm |
Wed, 20 Mar 2019 22:41:50 +0100 | |
changeset 69932 | 56c51f8a118b |
parent 64881 | 9eff4c62579a |
permissions | -rwxr-xr-x |
64881 | 1 |
#!/usr/bin/python3 -Es |
56417
04d0083cb9e5
churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff
changeset
|
2 |
|
04d0083cb9e5
churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff
changeset
|
3 |
import re |
04d0083cb9e5
churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff
changeset
|
4 |
import sys |
64881 | 5 |
import matplotlib.pyplot as plt |
6 |
from matplotlib.backends.backend_pdf import PdfPages |
|
7 |
||
8 |
output = PdfPages('chart.pdf') |
|
56417
04d0083cb9e5
churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff
changeset
|
9 |
|
04d0083cb9e5
churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff
changeset
|
10 |
re_entry = re.compile(R'^(.*\S+)\s+(\d+)\s*\**\s*$') |
04d0083cb9e5
churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff
changeset
|
11 |
|
64881 | 12 |
labels = [] |
13 |
values = [] |
|
56417
04d0083cb9e5
churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff
changeset
|
14 |
|
04d0083cb9e5
churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff
changeset
|
15 |
for line in sys.stdin.readlines(): |
64881 | 16 |
match = re_entry.match(line) |
17 |
labels.append(match.group(1)) |
|
18 |
values.append(match.group(2)) |
|
56417
04d0083cb9e5
churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff
changeset
|
19 |
|
64881 | 20 |
plt.pie(values, labels = labels) |
21 |
output.savefig() |
|
22 |
output.close() |