A box-whisker plot summarises a numeric variable's distribution in five numbers at a glance: minimum, first quartile, median, third quartile, and maximum.
How to Read a Boxplot
- The box spans the first quartile (Q1) to the third quartile (Q3) — the middle 50% of the data
- The line inside the box is the median
- The whiskers extend to the smallest/largest values within 1.5 x IQR of the box
- Points beyond the whiskers are plotted individually as outliers
A Basic Boxplot
R Code
scores <- c(55,60,62,65,70,72,75,95) boxplot(scores, main = "Exam Scores", col = "lightblue") summary(scores)
Output
Min. 1st Qu. Median Mean 3rd Qu. Max. 55.00 61.50 67.50 69.25 73.25 95.00
💡 Tip
In the example above, 95 sits far above the rest of the data and would typically show as a separate dot above the upper whisker - a quick visual flag that it may be an outlier worth investigating.Comparing Groups with a Formula
R Code
df <- data.frame( score = c(55,60,65, 80,85,90), group = c("A","A","A", "B","B","B") ) boxplot(score ~ group, data = df, main = "Score by Group", col = c("lightblue","lightgreen"))
Advanced: Extracting the Actual Statistics
🚀 Advanced Example
boxplot(), when assigned to a variable instead of just drawn, silently returns the exact numbers used to build it - useful for reporting the underlying values rather than just eyeballing the chart.R Code
result <- boxplot(scores, plot = FALSE) result$stats # min, Q1, median, Q3, max result$out # flagged outlier values
Output
[,1] [1,] 55.00 [2,] 61.50 [3,] 67.50 [4,] 73.25 [5,] 75.00 [1] 95
Key Points
- A boxplot shows the median, the middle 50% of data (the box), and whiskers extending to typical extremes.
- Points beyond the whiskers are flagged as potential outliers.
- score ~ group draws one box per group for easy visual comparison.
- boxplot(x, plot = FALSE) returns the underlying summary numbers without drawing anything.