-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fig1-ab.r
44 lines (39 loc) · 2.13 KB
/
Fig1-ab.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
library(ggplot2)
library(openxlsx)
dailyCases <- read.xlsx("TravelTimeSummary_China.xlsx", "Date of Symptom onset", detectDates=TRUE)
gpTrain <- ggplot(subset(dailyCases, Type == "Train"), aes(x=Day, y=Count)) +
geom_bar(fill="tomato1", stat="identity") +
geom_segment(aes(x=as.Date("2020-1-23"),xend=as.Date("2020-1-23"),y=0,yend=100), linetype=2, color="black", size=0.5) +
geom_segment(aes(x=as.Date("2020-1-25"),xend=as.Date("2020-1-25"),y=0,yend=100), linetype=2, color="blue", size=0.5) +
geom_segment(aes(x=as.Date("2020-1-29"),xend=as.Date("2020-1-29"),y=0,yend=100), linetype=2, color="green", size=0.5) +
scale_x_date(date_labels = "%m/%d", date_breaks = "10 days", limits = range(dailyCases$Day)) +
xlab("Date of Symptom onset") +
ylab("Cases number") +
labs(title = "Train") +
theme_light() +
theme(
axis.text = element_text(size=9),
axis.text.x = element_text(angle = -30, vjust=0.2),
axis.title = element_text(size=10,face="bold"),
plot.title = element_text(size=10, hjust=0.5)
)
gpAir <- ggplot(subset(dailyCases, Type == "Airplane"), aes(x=Day, y=Count)) +
geom_bar(fill="tomato1", stat="identity") +
geom_segment(aes(x=as.Date("2020-1-23"),xend=as.Date("2020-1-23"),y=0,yend=34), linetype=2, color="black", size=0.5) +
geom_segment(aes(x=as.Date("2020-1-25"),xend=as.Date("2020-1-25"),y=0,yend=34), linetype=2, color="blue", size=0.5) +
geom_segment(aes(x=as.Date("2020-1-29"),xend=as.Date("2020-1-29"),y=0,yend=34), linetype=2, color="green", size=0.5) +
scale_x_date(date_labels = "%m/%d", date_breaks = "10 days", limits = range(dailyCases$Day)) +
xlab("Date of Symptom onset") +
ylab("Cases number") +
labs(title = "Airplane") +
theme_light() +
theme(
axis.text = element_text(size=9),
axis.text.x = element_text(angle = -30, vjust=0.2),
axis.title = element_text(size=10,face="bold"),
plot.title = element_text(size=10, hjust=0.5)
)
gp <- ggpubr::ggarrange(gpAir,
gpTrain + theme(axis.title.y = element_blank(), plot.margin = margin(5,5,5,12,unit="pt")),
nrow = 1)
gp