Changes in / [f4fe7fd:b81ab1c6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/plot.py
rf4fe7fd rb81ab1c6 15 15 import numpy 16 16 import re 17 import statistics18 17 import sys 19 18 … … 41 40 } 42 41 43 def plot( in_data, x, y, out):42 def plot(data, x, y, out): 44 43 fig, ax = plt.subplots() 45 44 colors = itertools.cycle(['#0095e3','#006cb4','#69df00','#0aa000','#fb0300','#e30002','#fd8f00','#ff7f00','#8f00d6','#4b009a','#ffff00','#b13f00']) 46 series = {} # scatter data for each individual data point 47 groups = {} # data points for x value 48 for entry in in_data: 49 name = entry[0] 50 if not name in series: 51 series[name] = {'x':[], 'y':[]} 52 53 if not name in groups: 54 groups[name] = {} 45 series = {} 46 for entry in data: 47 if not entry[0] in series: 48 series[entry[0]] = {'x':[], 'y':[]} 55 49 56 50 if x in entry[2] and y in entry[2]: 57 xval = entry[2][x] 58 yval = entry[2][y] 59 series[name]['x'].append(xval) 60 series[name]['y'].append(yval) 61 62 if not xval in groups[name]: 63 groups[name][xval] = [] 64 65 groups[name][xval].append(yval) 66 67 lines = {} # lines from groups with min, max, median, etc. 68 for name, data in groups.items(): 69 if not name in lines: 70 lines[name] = { 'x': [], 'min':[], 'max':[], 'med':[], 'avg':[] } 71 72 for xkey in sorted(data): 73 ys = data[xkey] 74 lines[name]['x'] .append(xkey) 75 lines[name]['min'].append(min(ys)) 76 lines[name]['max'].append(max(ys)) 77 lines[name]['med'].append(statistics.median(ys)) 78 lines[name]['avg'].append(statistics.mean(ys)) 51 series[entry[0]]['x'].append(entry[2][x]) 52 series[entry[0]]['y'].append(entry[2][y]) 79 53 80 54 for name, data in series.items(): 81 _col = next(colors) 82 plt.scatter(data['x'], data['y'], color=_col, label=name, marker='x') 83 plt.plot(lines[name]['x'], lines[name]['min'], '--', color=_col) 84 plt.plot(lines[name]['x'], lines[name]['max'], '--', color=_col) 85 plt.plot(lines[name]['x'], lines[name]['med'], '-', color=_col) 55 plt.scatter(data['x'], data['y'], color=next(colors), label=name, marker='x') 86 56 87 57 mx = max([max(s['x']) for s in series.values()])
Note: See TracChangeset
for help on using the changeset viewer.