Box Plots
A box plot (or box-and-whisker plot) summarizes the distribution of a numeric variable using five key statistics - the minimum, first quartile, median, third quartile, and maximum - making it an efficient way to spot spread, skewness, and outliers at a glance.
Anatomy of a Box Plot
- Box - spans from the first quartile (Q1) to the third quartile (Q3), representing the middle 50% of the data (the interquartile range, or IQR)
- Line inside the box - marks the median (Q2)
- Whiskers - extend to the smallest and largest values within 1.5 times the IQR from the box
- Points beyond the whiskers - plotted individually as potential outliers
The IQR and Outlier Rule
IQR = Q3 - Q1
Lower bound = Q1 - 1.5 * IQR
Upper bound = Q3 + 1.5 * IQR
Any data point falling outside these bounds is typically flagged as a potential outlier.
Plotting in Python
import matplotlib.pyplot as plt
plt.boxplot(data, vert=True, patch_artist=True)
plt.ylabel("Value")
plt.title("Box Plot")
plt.show()
Comparing Groups
Box plots are especially useful for comparing distributions across multiple groups side by side - for example, comparing exam scores across several different classes in a single chart.
Coming Up Next
To explore the relationship between two continuous variables rather than the distribution of just one, the final chart type to cover is the Scatter Plot.