Bin

noun

say it: “BIN” /ˈbɪn/

One range of values in a histogram, such as $5 to $10; its bar shows how many values fall in that range.

What is a bin in a histogram?

A bin is one range of values in a histogram, such as orders from $5 to $10. Each value is counted in the bin it falls in, and the bin's bar is as tall as that count. ax.hist() makes 10 bins unless bins= asks for another number or lists the edges.

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.hist([4.25, 6.50, 12.00, 14.75], bins=[0, 5, 10, 15])
# three bins, $0-5, $5-10 and $10-15: bars of 1, 1 and 2 orders

In a sentence

  • “An order of $6.50 lands in the $5 to $10 bin.”
  • “Each bin in the histogram was $5 wide.”

Level: Apprentice · More Python terms at this level

Updated