MCPcopy Index your code
hub / github.com/glamp/bashplotlib / calc_bins

Function calc_bins

bashplotlib/histogram.py:20–34  ·  view source on GitHub ↗

Calculate number of bins for the histogram

(n, min_val, max_val, h=None, binwidth=None)

Source from the content-addressed store, hash-verified

18
19
20def calc_bins(n, min_val, max_val, h=None, binwidth=None):
21 """
22 Calculate number of bins for the histogram
23 """
24 if not h:
25 h = max(10, math.log(n + 1, 2))
26 if binwidth == 0:
27 binwidth = 0.1
28 if binwidth is None:
29 binwidth = (max_val - min_val) / h
30 for b in drange(min_val, max_val, step=binwidth, include_stop=True):
31 if b.is_integer():
32 yield int(b)
33 else:
34 yield b
35
36
37def read_numbers(numbers):

Callers 1

plot_histFunction · 0.85

Calls 1

drangeFunction · 0.85

Tested by

no test coverage detected