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.
flowchart LR A["Raw numeric values"] --> B["Split into N equal-width bins"] B --> C["Count values per bin"] C --> D["Draw one bar per bin"] D --> E["Shape reveals skew, outliers, spread"]
Basic histogram
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()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()Try different bins
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()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()Visualize it
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):
Tip
Histograms are a first check before transformations (like log scaling).
Next
Continue to Scatter Plot to check the relationship between two numeric variables.
🧪 Try It Yourself
Exercise 1 – Set the bin count
Exercise 2 – Read the bin counts
Exercise 3 – Compare bin widths
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
