termgraph
termgraph copied to clipboard
Why does the histogram not show all the values in the data?
Thanks for making this tool. I am not sure if this is a bug, or I am missing something, but I wanted to bring it up.
Shouldn't the values for each of the bins add up to 3 since there are 3 rows in the data?
§ termgraph --version
termgraph v0.4.2
§ echo $'1 100\n2 200\n3 300' | termgraph --histogram
100 – 140.0: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 1.00
140.0 – 180.0: 0.00
180.0 – 220.0: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 1.00
220.0 – 260.0: 0.00
260.0 – 300.0: 0.00
Also, if the input has values that are same, there is an error:
§ echo $'1 100\n2 100' | termgraph --histogram
Traceback (most recent call last):
File "/usr/local/bin/termgraph", line 10, in <module>
sys.exit(main())
File "/Library/Python/3.7/site-packages/termgraph/termgraph.py", line 130, in main
chart(colors, data, args, labels)
File "/Library/Python/3.7/site-packages/termgraph/termgraph.py", line 478, in chart
for row in hist_rows(data, args, colors):
File "/Library/Python/3.7/site-packages/termgraph/termgraph.py", line 217, in hist_rows
normal_counts = normalize(count_list, args["width"])
File "/Library/Python/3.7/site-packages/termgraph/termgraph.py", line 162, in normalize
norm_factor = width / float(max_datum)
ZeroDivisionError: float division by zero