A notched boxplot narrows the box around each median to display an approximate confidence interval. Comparing groups becomes easier: non-overlapping notches provide strong evidence that their medians differ. section 14.5.1
p3 <- ggplot(nba_stats, aes(x = o_pts_cat, y = z_wins, fill = o_pts_cat)) +
geom_boxplot(notch = TRUE, alpha = 0.5) +
labs(title = "Points Allowed vs. Wins",
subtitle = "2008-17",
x = "Standardized Points Allowed Category",
y = "Standardized Regular Season Wins") +
stat_summary(fun = mean, geom = "point",
shape = 20, size = 8, color = "white", fill = "white") +
theme(legend.position = "bottom") +
scale_fill_discrete(name = "Points\nAllowed\nZ-Score",
labels = c("< -1", "-1 to 0", "0 to 1","> 1")) +
theme(plot.title = element_text(face = "bold"))
Build the chart with ggplot2 by mapping a category to x, standardized wins to y, and setting notch = TRUE in geom_boxplot(). section 14.5.1
NBA scoring and wins
Plot standardized regular-season wins across standardized points-allowed or points-scored categories. Add white mean points with stat_summary(), then compare the notches across categories. section 14.5.1
