#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Plot a histogram of the input data stream using Matplotlib

Author: Gertjan van den Burg
License: See LICENSE file
Copyright (c) 2020, G.J.J. van den Burg

"""

import argparse
import matplotlib.pyplot as plt
import sys


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('-b','--bins', help='Number of bins to use', type=int)
    return parser.parse_args()


def main():
    args = parse_args()
    values = []
    for line in sys.stdin:
        if not line.strip():
            continue
        values.append(float(line.strip()))
    plt.hist(values, bins=args.bins)
    plt.show()


if __name__ == "__main__":
    main()
