-
Notifications
You must be signed in to change notification settings - Fork 1
/
Figure4_NO2.R
46 lines (33 loc) · 1.34 KB
/
Figure4_NO2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
### Code to plot NO2 mean difference of PE for the years 2019 and 2020
library(readxl)
library(tidyverse)
library(boot)
library(ggthemes)
library(grid)
library(gridExtra)
library(forecast)
library(data.table)
library(cowplot)
df_all_plot <- read.csv('df_box_NO2_2019_2020_Jan_Apr.csv')
df_all_plot$Year = factor(df_all_plot$Year)
state.abb = as.character(unique(df_all_plot$state))
df_no2_summary.2 = data.frame(df_no2_summary)
df_no2_summary.2$Year = as.numeric(as.character(df_no2_summary.2$Year))
df_wide_no2 <- reshape(df_no2_summary.2, direction = "wide", v.names="no2", timevar="Year", idvar="state")
png("figures/NO2_2019_2020_mean_difference.png", height = 1000, width=1500)
no2.plot <- ggplot(df_no2_summary, aes(x=state, y=no2, colour=Year)) +
geom_point(size=5)+
geom_hline(yintercept = 0)+
geom_segment(aes(x=state, xend=state, y=no2.2019, yend=no2.2020),
size=1, data=df_wide_no2, colour="black", linetype="dotted")+
theme_classic()+
theme(plot.title = element_text(hjust = 0.5))+
theme(axis.text.x = element_text(size = 14, angle = 45),
axis.text.y = element_text(size = 14),
axis.title = element_text(size = 16),
legend.title = element_text(size=14), #change legend title font size
legend.text = element_text(size=14))+
xlab("State")+
ylab("NO2 mean difference")
no2.plot
dev.off()