# One panel per region; within each panel, one ECDF for each assault level
col_high <- rgb(1, 0, 0, .5)
col_low <- rgb(0, 0, 1, .5)
par(mfrow=c(2, 2), oma=c(0, 0, 3, 0))
for (r in levels(xy_hat$Region)) {
xy_r_hat <- xy_hat[xy_hat$Region == r, ]
plot(NULL, xlim=range(xy_hat$Murder), ylim=c(0, 1),
xlab='Murder arrests (per 100,000)', ylab='Proportion of states', main=NA)
F_lo_hat <- ecdf(xy_r_hat$Murder[xy_r_hat$AssaultLevel == 'Low assault'])
F_hi_hat <- ecdf(xy_r_hat$Murder[xy_r_hat$AssaultLevel == 'High assault'])
plot(F_lo_hat, add=TRUE, col=col_low, lwd=2, verticals=TRUE, do.points=FALSE, col.01line=NA)
plot(F_hi_hat, add=TRUE, col=col_high, lwd=2, verticals=TRUE, do.points=FALSE, col.01line=NA)
title(r, font.main=1)
}
# One legend for all four panels, drawn on an invisible full-figure overlay
par(fig=c(0, 1, 0, 1), oma=c(0, 0, 0, 0), mar=c(0, 0, 0, 0), new=TRUE)
plot(0, 0, type='n', bty='n', xaxt='n', yaxt='n')
legend('top', horiz=TRUE, bty='n',
legend=c('Low assault', 'High assault'), col=c(col_low, col_high), lwd=2)