Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
import pylab as pl
import numpy as np
import random
import sys
stat = {}
#each measure should be prefixed by character ':'
for l in sys.stdin:
if l[0:1] == ':':
words = l[1:].split()
num = float(words[-1])
label = ' '.join(words[:-1])
stat.setdefault(label, []).append(num)
stat = list(sorted(stat.items(), key = lambda (label, vals): (np.median(vals), label))) #sort by median value
def error_pair(vals):
a, b = np.percentile(vals, [10, 90])
val = np.median(vals)
return (val, val-a, b-val)
pl.xlabel('secods of run time')
pl.title('performance of different cum-sum funtions')
pl.subplots_adjust(bottom=0, left=.4, right=.99, top=.90, hspace=.35) #too long labels spans left right without adjust
ypos = np.arange(len(stat))+.5 #vertical positions
val, err_low, err_hi = zip(*[error_pair(time_values) for label, time_values in stat])
xerr=[err_low, err_hi],
ecolor='r', align='center'
#green dots to plot every measurement
xdots = []
ydots = []
for y, (labels, xs) in zip(ypos, stat):
for x in xs:
ydots.append(y + random.uniform(-0.3, + 0.3)) #random vertical jitter
pl.plot(xdots, ydots, 'gx', alpha=0.3)
pl.yticks(ypos, [label for label, time_values in stat]) #label for each bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment