Skip to content

Commit ccfde87

Browse files
author
Mackenzie
committed
max values and y-val of 0
include max data values (previously were left out of plot) include max y values (previously were left off of y axis) show y scale such that height of column in histogram corresponds to correct y value (previously corresponded to y-1) no need to include 0 in ys. Rather, start ys at min of 1, and leave cols with y val of 0 empty.
1 parent 6bf4681 commit ccfde87

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bashplotlib/histogram.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="",
8686
hist[i] = 0
8787
for number in read_numbers(f):
8888
for i, b in enumerate(bins):
89-
if number < b:
89+
if number <= b:
9090
hist[i] += 1
9191
break
92+
if number == max_val and max_val > bins[len(bins) - 1]:
93+
hist[len(hist) - 1] += 1
9294

9395
min_y, max_y = min(hist.values()), max(hist.values())
9496

95-
ys = list(drange(min_y, max_y, (max_y-min_y)/height))
97+
ys = list(drange(max(min_y, 1), max_y + 1, (max_y-min_y)/height))
9698
ys.reverse()
9799

98100
nlen = max(len(str(min_y)), len(str(max_y))) + 1
@@ -112,7 +114,7 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="",
112114
print ylab,
113115

114116
for i in range(len(hist)):
115-
if y < hist[i]:
117+
if int(y) <= hist[i]:
116118
printcolor(pch, True, colour)
117119
else:
118120
printcolor(" ", True, colour)

0 commit comments

Comments
 (0)