merged |>
ggplot() +
aes(x = month_label) +
geom_line(aes(y = p_expected, group = 1),
linetype = "dashed") +
geom_linerange(aes(ymin = p_births, ymax = p_nhl)) +
geom_point(aes(y = p_births, color = "Canadian Population"), size = 3) +
geom_point(aes(y = p_nhl, color = "Canadian NHL Players"), size = 3) +
geom_text(aes(label = scales::percent(p_births, accuracy = 0.01),
y = if_else(p_births > p_nhl, p_births + .007,
p_births - .007)), size = 3) +
geom_text(aes(label = scales::percent(p_nhl, accuracy = 0.007),
y = if_else(p_nhl > p_births, p_nhl + .01,
p_nhl - .007)), size = 3) +
coord_flip() +
scale_x_discrete(limits = rev(levels(merged$month_label))) +
labs(x = "Birth Month",y = "Percent")+
scale_color_manual(values = my_pal) +
theme_bw() +
theme(legend.position = "bottom",
legend.title = element_blank(),
axis.text.y=element_text(color="black",size=10,face="bold"),
axis.text.x=element_text(color="black",size=10,face="bold"),
axis.title.x = element_text(margin = margin(t = 0.5,unit="cm"),
color="black",face="bold"),
axis.title.y = element_text(margin = margin(r = 0.5,unit="cm"),
color="black",face="bold"),
plot.margin = margin(0.5,1,0.5,0.5,unit="cm"))