@@ -0,0 +1,2025 @@
+#!/usr/bin/env python3%0A%0Aimport sys, random%0Afrom argparse import ArgumentDefaultsHelpFormatter, ArgumentParser%0Aimport matplotlib; matplotlib.use('Agg') # for systems without X11%0Afrom matplotlib.backends.backend_pdf import PdfPages%0Aimport pylab as plt%0Aimport numpy as np%0Aimport random%0A%0Aplt.rcParams.update(%7B%0A    'axes.grid' : True,%0A%7D)%0A%0A## helper - cumulative fraction for y axis%0Adef cf(d): return plt.arange(1.0,float(len(d))+1.0)/float(len(d))%0A%0A## helper - return step-based CDF x and y values%0Adef getcdf(data):%0A    data.sort()%0A    frac = cf(data)%0A    x, y, lasty = %5B%5D, %5B%5D, 0.0%0A    for i in range(len(data)):%0A        assert not np.isnan(data%5Bi%5D)%0A        x.append(data%5Bi%5D)%0A        y.append(lasty)%0A        x.append(data%5Bi%5D)%0A        y.append(frac%5Bi%5D)%0A        lasty = frac%5Bi%5D%0A    return x, y%0A%0Adef main(args):%0A    values = %5B%5D%0A    for line in sys.stdin:%0A        line = line.strip() %0A        try: values.append(float(line))%0A        except: print('ignoring', line)%0A    if args.max_points %3E= 0 and len(values) %3E args.max_points:%0A        values = random.sample(values, args.max_points)%0A    with PdfPages(args.output) as pdf:%0A        plt.figure()%0A        plt.plot(*getcdf(values))%0A        plt.ylim(ymin=0, ymax=1)%0A        plt.xlim(xmin=min(values), xmax=max(values))%0A        if args.label: plt.xlabel(args.label)%0A        if args.title: plt.title(args.title)%0A        plt.ylabel('CDF')%0A        pdf.savefig()%0A%0Aif __name__=='__main__':%0A    parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter,%0A        description='Take a list of values on stdin, one value per line, and '%0A        'plot a CDF of them')%0A    parser.add_argument('-o', '--output', default='temp.pdf')%0A    parser.add_argument('-l', '--label', type=str,%0A        help='What to label the data in the PDF')%0A    parser.add_argument('-t', '--title', type=str,%0A        help='What to title the plot in the PDF')%0A    parser.add_argument('--max-points', default=10000, type=int,%0A        help='Negative means infinite')%0A    args = parser.parse_args()%0A    exit(main(args))%0A

Add plot-cdf.py