Skip to content

Instantly share code, notes, and snippets.

@tipabu
Created April 25, 2017 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tipabu/454d8859d997110ba0acbca36ab6b7ec to your computer and use it in GitHub Desktop.
Save tipabu/454d8859d997110ba0acbca36ab6b7ec to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from __future__ import division
import argparse
from collections import defaultdict, OrderedDict
import json
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
from operator import itemgetter
import numpy as np
import math
import os
import random
import re
import sys
from pprint import pprint
from cStringIO import StringIO
colors = {
'8 + 16': 'blue',
'2x(8 + 4)': 'green',
'2x8 + 8': 'red',
'3x8 + 0': 'black',
}
graphs = (
('global', 'Global Durability\n(%s)', lambda x: x['can_reconstruct']),
('regional', 'Per-Region Durability\n(%s)',
lambda x: x['per_region']['can_reconstruct']),
)
for j, name in enumerate(('isa_l_rs_vand', 'isa_l_rs_cauchy')):
with open('%s.json' % name, 'rb') as fp:
df = json.load(fp, object_pairs_hook=OrderedDict)
for i, (mode, title, extractor) in enumerate(graphs):
plt.figure(j*len(graphs) + i)
plt.title(title % name)
plt.xlabel('Partition Failures')
plt.ylim([0, 1])
plt.ylabel('P[Can reconstruct]')
for label, data in df.items():
data_points = [(int(x), extractor(y)) for x, y in data.items()]
plt.plot(*zip(*data_points), label=label, color=colors[label],
marker='o', markersize=4)
plt.legend()
plt.savefig('%s_%s.png' % (name, mode), dpi=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment