stat_lorenz() is a gglorenz plotting statistic for drawing Lorenz curves inside a ggplot2 workflow. Map a numeric variable, choose the population order, and compare the curve with a perfect-equality diagonal. section 12.6 section 13.5
A typical workflow is:
- Filter the data to one season or comparison group. section 12.6
- Initialize ggplot() with the filtered data and the variable whose distribution will be evaluated. section 12.6
- Add stat_lorenz(desc = FALSE) for ascending population order; set color, line width, or geom = "polygon" as needed. section 12.6 section 13.5
- Use coord_fixed(), geom_abline(), and percentage scales to make inequality comparisons easier to interpret. section 12.6
NBA salary distribution
Filter gini4 to season_end == 1994, map salary, and add stat_lorenz(desc = FALSE, color = "red", lwd = 2). The resulting curve accompanies a Gini coefficient of 0.39 for the 1993–94 season. section 12.6
ggplot(gini9117, aes(WS, fill = Year)) +
stat_lorenz(geom = "polygon", desc = FALSE) +
coord_fixed() +
geom_abline(linetype = "dashed") +
labs(title = "Lorenz Curve\n1990-91 versus 2016-17 Seasons",
subtitle = "Gini coefficients = 0.56 and 0.49",
x = "Win Share Distribution",
y = "Percentage of NBA Players",
caption = "includes a maximum top 14 salaries for each team") +
scale_x_continuous(labels = percent) +
scale_y_continuous(labels = percent) +
theme(plot.title = element_text(face = "bold"))
Inspect a consolidated stat_lorenz() plot comparing 1990–91 and 2016–17 win-share distributions with separate fills. section 13.5
