Skip to content

Histogram

A histogram is really a bar plot in disguise: McKinney describes it as “a discretized display of value frequency.” Your values get split into evenly spaced bins, and the bar height for each bin is simply how many values landed inside it.

diagram From raw values to a histogram mermaid
Values are split into evenly spaced bins, then a bar is drawn per bin showing how many values fall inside it.
Histogram
import matplotlib.pyplot as plt
 
values = [55, 60, 62, 63, 65, 67, 70, 72, 76, 80, 81, 85, 90, 92, 95]
 
plt.figure(figsize=(7, 4))
plt.hist(values, bins=8, edgecolor="black")
plt.title("Distribution")
plt.xlabel("Value")
plt.ylabel("Count")
plt.tight_layout()
plt.show()
Bins
import matplotlib.pyplot as plt
 
fig, axes = plt.subplots(1, 2, figsize=(10, 4), sharey=True)
 
axes[0].hist(values, bins=4, edgecolor="black")
axes[0].set_title("bins=4")
 
axes[1].hist(values, bins=12, edgecolor="black")
axes[1].set_title("bins=12")
 
plt.tight_layout()
plt.show()

A histogram sorts your values into bins and draws a bar for each — the bar’s height is how many values landed in that bin. Together the bars reveal the shape of the distribution (here, a bell centred near the middle):

sketch A histogram bins your data p5.js
Each value falls into a bin; the bar height is the count in that bin, revealing the distribution's shape.

Histograms are a first check before transformations (like log scaling).

Continue to Scatter Plot to check the relationship between two numeric variables.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading