Histograms

A histogram visualizes the distribution of a single continuous variable by dividing its range into intervals (called bins) and showing how many data points fall into each bin.

Histogram vs Bar Chart

Although they look similar, histograms and bar charts serve different purposes - a bar chart compares distinct categories, while a histogram shows the distribution of a single continuous variable, with bars touching each other since the bins represent a continuous range.

Choosing the Number of Bins

Too few bins can oversimplify the distribution and hide important patterns, while too many bins can make the chart noisy and hard to interpret - there's no single "correct" number, but it's worth experimenting with a few different bin counts.

Plotting in Python

import matplotlib.pyplot as plt

plt.hist(data, bins=20, color="coral", edgecolor="black")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.title("Distribution of Values")
plt.show()

What to Look For

  • Shape - is the distribution symmetric, skewed left, or skewed right?
  • Peaks - is it unimodal (one peak) or multimodal (multiple peaks)?
  • Outliers - are there unusually high or low values sitting far from the rest?
  • Spread - how wide or narrow is the range of values?
Histograms are one of the fastest ways to spot skewness in your data - a critical first step before applying statistical tests or models that assume a roughly normal distribution.

Coming Up Next

Next, let's look at a chart type used to show proportions of a whole rather than distribution - the Pie Chart.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course