This repository has been archived on 2020-10-03. You can view files and clone it, but cannot push or open issues or pull requests.
pgai_tp1/util/plot.py

15 lines
632 B
Python
Executable File

#!/bin/python3
import sys
from matplotlib import pyplot as plt
data = list(map(float, sys.stdin.readline().split()))
vals, bins, _ = plt.hist(data, color='deeppink',
bins=10 if len(sys.argv) == 1 else int(sys.argv[1]),
range=(float(sys.argv[2]), float(sys.argv[3])) if len(sys.argv) == 4 else None)
for i, v in zip([a + (b-a) / 2 for a, b in zip(bins, bins[1:])], vals):
plt.text(i, v, str(int(v)), color='darkviolet', ha='center', fontweight='bold')
plt.xticks(ticks=bins,
labels=list(map(lambda e: f'{e:.5}', bins)),
rotation=30, ha='right')
plt.show()