cut_short_scale() is a scales-package helper for making large numeric values easier to read on ggplot2 axes. It replaces long values with abbreviated scale suffixes, such as M for millions. Combined with label_dollar(), it turns 20000000 into a readable $20 M label. section 10.4.2
Use it inside scale_x_continuous() or scale_y_continuous() through the scale_cut argument. The underlying data remains numeric, while only the displayed axis labels are shortened. section 10.4.2 section 10.4.3
Typical applications include:
- Format team payrolls in dot plots without displaying unwieldy seven- or eight-digit numerals. section 10.4.2
- Display average payrolls in lollipop charts while preserving the original numeric means for plotting and comparison. section 10.4.3
- Label salary spending per regular-season win with values such as $1M, $2M, and $3M. section 11.4.2
Format an NBA payroll axis
A dot plot can keep payroll values numeric and apply readable dollar labels with: scale_x_continuous(labels = label_dollar(scale_cut = cut_short_scale())). The same pattern works for a y-axis by replacing scale_x_continuous() with scale_y_continuous().
salaries2000 <- select(salaries, Team, s2000, pc2000)
salaries2000 <- na.omit(salaries2000)
dot1 <- ggplot(salaries2000) +
geom_point(aes(x = s2000, y = reorder(Team, s2000),
color = factor(pc2000)), size = 3) +
labs(title= "NBA Team Payrolls (USD)",
subtitle = "1999-2000",
x = "Team Payroll",
y = "") +
scale_x_continuous(labels = label_dollar(scale_cut = cut_short_scale())) +
theme(plot.title = element_text(face = "bold")) +
scale_color_manual(name = "",
labels = c("No playoffs",
"Made playoffs",
"Won title"),
values = c("0" = "navy",
"10" = "gold3",
"11" = "red")) +
theme(legend.position = "bottom") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Inspect a complete payroll dot-plot listing that combines cut_short_scale() with dollar prefixes, reordered teams, outcome colors, and rotated axis text. section 10.4.2
