Box Plot
ggplot2: geom_boxplot() · Package: ggplot2 · Variables: 1 numerical + 0-1 categorical
WHAT IS A BOX PLOT?
A box plot (also called a box-and-whisker plot) provides a compact five-number summary: minimum, first quartile (Q1), median, third quartile (Q3), and maximum — with outliers shown as individual points. It is the most space-efficient way to compare distributions across multiple groups. Box plots answer "how does the spread and center of group A compare to group B?" They work well with 3-20 groups and are standard in scientific and statistical reporting. Note that box plots hide distribution shape (bimodality) — consider violin plots if shape matters. In ggplot2, use geom_boxplot().
BEST FOR
- · Comparing distributions across groups
- · Identifying outliers
- · Compact summary
- · 3-20 groups
AVOID WHEN
- · Non-technical audience
- · When distribution shape matters (bimodality hidden)
- · Very small samples
R + GGPLOT2 CODE EXAMPLE
ggplot(mtcars, aes(x = factor(cyl), y = mpg)) + geom_boxplot(fill = "#ff6a00", alpha = 0.7) + labs(title = "MPG by Cylinder Count", x = "Cylinders", y = "MPG")
Run this code now
Paste the code above into RChat and see the box plot rendered instantly in your browser.