Admin/lib/scripts/churn_pie
author wenzelm
Wed, 07 Aug 2024 20:06:55 +0200
changeset 80666 cdae621613da
parent 64881 9eff4c62579a
permissions -rwxr-xr-x
more robust: only type inference with its finish/fixate phase (on contrast to dc387e3999ec), e.g. avoid accidental "improvement" of type class operations (free vs. const);

#!/usr/bin/python3 -Es

import re
import sys
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages

output = PdfPages('chart.pdf')

re_entry = re.compile(R'^(.*\S+)\s+(\d+)\s*\**\s*$')

labels = []
values = []

for line in sys.stdin.readlines():
    match = re_entry.match(line)
    labels.append(match.group(1))
    values.append(match.group(2))

plt.pie(values, labels = labels)
output.savefig()
output.close()