improved chart plotting
authorhaftmann
Wed, 11 Jan 2017 22:30:11 +0100
changeset 64881 9eff4c62579a
parent 64880 3f36c53aa105
child 64882 c3b42ac0cf81
improved chart plotting
Admin/lib/Tools/churn_pie
Admin/lib/scripts/churn_pie
--- a/Admin/lib/Tools/churn_pie	Wed Jan 11 22:08:20 2017 +0100
+++ b/Admin/lib/Tools/churn_pie	Wed Jan 11 22:30:11 2017 +0100
@@ -11,4 +11,4 @@
 
 cd "$(dirname "$ALIAS")"
 
-hg churn --aliases "$ALIAS" | "$SCRIPT" "$@" 
+hg churn --aliases "$ALIAS" | "$SCRIPT" "$@"
--- a/Admin/lib/scripts/churn_pie	Wed Jan 11 22:08:20 2017 +0100
+++ b/Admin/lib/scripts/churn_pie	Wed Jan 11 22:30:11 2017 +0100
@@ -1,23 +1,22 @@
-#!/usr/bin/env python
+#!/usr/bin/python3 -Es
 
 import re
-from pychart import theme, pie_plot, area, fill_style, arrow, legend
 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*$')
 
-theme.get_options()
-
-data = []
+labels = []
+values = []
 
 for line in sys.stdin.readlines():
-    match = re_entry.match(unicode(line, 'utf-8'))
-    data.append((match.group(1), int(match.group(2))))
+    match = re_entry.match(line)
+    labels.append(match.group(1))
+    values.append(match.group(2))
 
-plot = pie_plot.T(data = data, arc_offsets = [],
-  shadow = (2, -2, fill_style.gray50), label_offset = 10, arrow_style = arrow.a3)
-
-ar = area.T(size = (500, 500), legend = legend.T(), x_grid_style = None, y_grid_style = None)
-ar.add_plot(plot)
-
-ar.draw()
+plt.pie(values, labels = labels)
+output.savefig()
+output.close()