equal
deleted
inserted
replaced
1 #!/usr/bin/env python |
1 #!/usr/bin/python3 -Es |
2 |
2 |
3 import re |
3 import re |
4 from pychart import theme, pie_plot, area, fill_style, arrow, legend |
|
5 import sys |
4 import sys |
|
5 import matplotlib.pyplot as plt |
|
6 from matplotlib.backends.backend_pdf import PdfPages |
|
7 |
|
8 output = PdfPages('chart.pdf') |
6 |
9 |
7 re_entry = re.compile(R'^(.*\S+)\s+(\d+)\s*\**\s*$') |
10 re_entry = re.compile(R'^(.*\S+)\s+(\d+)\s*\**\s*$') |
8 |
11 |
9 theme.get_options() |
12 labels = [] |
10 |
13 values = [] |
11 data = [] |
|
12 |
14 |
13 for line in sys.stdin.readlines(): |
15 for line in sys.stdin.readlines(): |
14 match = re_entry.match(unicode(line, 'utf-8')) |
16 match = re_entry.match(line) |
15 data.append((match.group(1), int(match.group(2)))) |
17 labels.append(match.group(1)) |
|
18 values.append(match.group(2)) |
16 |
19 |
17 plot = pie_plot.T(data = data, arc_offsets = [], |
20 plt.pie(values, labels = labels) |
18 shadow = (2, -2, fill_style.gray50), label_offset = 10, arrow_style = arrow.a3) |
21 output.savefig() |
19 |
22 output.close() |
20 ar = area.T(size = (500, 500), legend = legend.T(), x_grid_style = None, y_grid_style = None) |
|
21 ar.add_plot(plot) |
|
22 |
|
23 ar.draw() |
|