In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
import pickle 

with open('data.pickle') as f:
    data = pickle.load(f)
    
packets = data['packet']

In [3]:
to_plot = (('dell', '2.7.8'),
           ('dell', 'pypy-2.3.1'),

           ('odroid', '2.7.8'),
           ('odroid', 'pypy-2.3.1'),
           
           ('pi', '2.7.8'),
           ('pi', 'pypy-2.3.1'))

In [6]:
indices = array([0.5, 1.0, 
                 2.0, 2.5,
                 3.5, 4.0])

color = {'serial': 'b',
         'forged': 'r',
         'pypot': 'g'}

width = 0.4

with xkcd():
    fig = plt.figure()
    ax = fig.add_axes((0.1, 0.2, 0.8, 0.7))
    
    for s in ['pypot', 'forged', 'serial']:
        x = [mean(packets[s][b][p]) * 1000 for b, p in to_plot]
        ax.bar(indices, x, width, color=color[s])
    
    ax.spines['right'].set_color('none')
    ax.spines['top'].set_color('none')
    ax.xaxis.set_ticks_position('bottom')
    ax.yaxis.set_ticks_position('left')

    ax.set_xticks(indices + width/2)
    
    ax.set_xticklabels(['2.7.8\n               PC',
                        'PyPy',
                        '2.7.8\n             Odroid',
                        'PyPy',
                        '2.7.8\n                Raspberry pi',
                        'PyPy'])

    plt.ylabel('time (ms)')
    plt.title("BOARDS COMPARISON")
    legend(['pypot', 'preforged-packet', 'raw serial'], loc='best')
    savefig('packet.png')



In [ ]: