WeCodeAcademy

Histograms

A histogram shows how a single set of numbers is spread out. The range is cut into bins (equal-width intervals) and each bar shows how many values fall into its bin. Tall bars mark where most of the data sits; the overall shape reveals whether it is symmetric, lopsided or has more than one peak.

ax.hist(data, bins=5) draws it. The call also returns the counts per bin, the bin edges and the bars. The number of bins changes the picture: too few hides the shape, too many looks jagged.

Examplepython
Open in editor »
Quick check

What does the height of a histogram bar show?

Your turn: write the code

Draw a histogram with the bin edges [0, 10, 20, 30, 40] and print the count in each bin as a list of whole numbers.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.