blob: 8450ec83e6f622663a2a60fd4e7f987865636174 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/env python3
import argparse
ticks = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]
parser = argparse.ArgumentParser()
parser.add_argument(
"numbers", metavar="N", type=float, nargs="+", help="a number for the accumulator"
)
args = parser.parse_args()
def histogram(sequence):
min_val = min(sequence)
max_val = max(sequence)
scale = (int(max_val - min_val) << 8) / (len(ticks) - 1)
if scale < 1:
scale = 1
return [ticks[int((int(i - min_val) << 8) / scale)] for i in sequence]
h = histogram(args.numbers)
print("".join(h))
|