Histogram
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()Tip
Histograms are a first check before transformations (like log scaling).
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
