library(haven) DATA <- read_dta(file.choose()) library(tidyverse) DATA$year <- factor(DATA$year) ggplot(DATA, aes(x=week_no, y=mass_shooting_total, group=year, color=year)) + geom_line(size=1.2) + scale_color_manual(values=c("gray", "black", "white")) + scale_y_continuous(limits=c(0,45), breaks=seq(0,45,5), labels=scales::number_format(accuracy=1), expand=c(0,0), sec.axis=dup_axis()) + geom_vline(xintercept=10, size=1.2, col="red3") + geom_vline(xintercept=21, size=1.2, col="blue3") + annotate("text", x=9 , y=43, size=5, angle=90, hjust=1, col="red3" , label="Week before covid declaration") + annotate("text", x=20, y=43, size=5, angle=90, hjust=1, col="blue3", label="Week before George Floyd") + labs(title="Mass Shootings", caption="Data source: Jaclyn Schildkraut and Jillian J. Turanovic. 2022. \"A New Wave of Mass Shootings?\nExploring the Potential Impact of COVID-19\". Homicide Studies. DOI: 10.1177/10887679221101605. https://osf.io/5xmsr/") + theme( axis.text.x = element_text(size=15, color="black", angle=90, vjust=0.5), axis.text.y = element_text(size=15, color="black", vjust=0.5, margin=margin(r=8,l=8)), axis.text.y.right = element_text(size=15, color="black", vjust=0.5, margin=margin(r=8,l=8)), axis.ticks.x = element_blank(), axis.ticks.y = element_blank(), axis.title.x = element_blank(), axis.title.y = element_blank(), axis.title.y.right = element_blank(), legend.position = "bottom", legend.spacing.x = unit(10, "pt"), legend.spacing.y = unit(10, "pt"), legend.text = element_text(size=15, margin=margin(t=5)), legend.title = element_text(size=15, face="bold"), panel.background = element_rect(size=0.5, color="black", fill="gray90", linetype="solid"), panel.border = element_rect(size=1.8, color="black", fill=NA , linetype="solid"), panel.grid.major.x = element_blank(), panel.grid.major.y = element_blank(), panel.grid.minor.x = element_blank(), panel.grid.minor.y = element_blank(), panel.spacing.x = unit(1, "lines"), panel.spacing.y = unit(1, "lines"), plot.background = element_rect(fill="white"), plot.caption = element_text(size=12, hjust=0 , margin=margin(t=10)), plot.margin = unit(c(t=10,r=10,b=10,l=10), "pt"), plot.subtitle = element_text(size=15, hjust=0.5, margin=margin(b=7)), plot.title = element_text(size=20, hjust=0.5, face="bold", margin=margin(t=0,b=15)), ) ggsave(file="G:Schildkraut and Turanovic 2022 Mass Shootings TOTAL.svg", width=13, height=7)