Admin/lib/scripts/churn_pie
author wenzelm
Sun, 28 Apr 2019 22:22:29 +0200
changeset 70207 511352b4d5d3
parent 64881 9eff4c62579a
permissions -rwxr-xr-x
tuned -- according to main website;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64881
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
     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
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
     5
import matplotlib.pyplot as plt
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
     6
from matplotlib.backends.backend_pdf import PdfPages
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
     7
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
     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
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
    12
labels = []
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
    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
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
    16
    match = re_entry.match(line)
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
    17
    labels.append(match.group(1))
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
    18
    values.append(match.group(2))
56417
04d0083cb9e5 churning pie charts (with non-canonical prerequisites!)
haftmann
parents:
diff changeset
    19
64881
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
    20
plt.pie(values, labels = labels)
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
    21
output.savefig()
9eff4c62579a improved chart plotting
haftmann
parents: 64879
diff changeset
    22
output.close()