-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolygonFun.R
More file actions
32 lines (28 loc) · 1.15 KB
/
polygonFun.R
File metadata and controls
32 lines (28 loc) · 1.15 KB
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
my4cols <- c("black", "green", "blue", "red")
my4labels <- c("disease 1", "disease 2", "disease 3", "disease4")
polygonFun <- function(time, poly1, poly2, poly3, poly4){
mm <- c(time, rev(time))
poly1a <- c(rep(0, length(time)), rev(poly1))
poly2a <- c(rep(0, length(time)), rev(poly2))
poly3a <- c(rep(0, length(time)), rev(poly3))
poly4a <- c(rep(0, length(time)), rev(poly4))
aa <- c(poly1, rev(poly1))
bb <- c(poly2+poly1, rev(poly1))
cc <- c(poly3+poly2+poly1, rev(poly2+poly1))
dd <- c(poly4+poly3+poly2+poly1, rev(poly3+poly2+poly1))
plot(time, poly1, xaxt="n", type="n", ylim=c(0,max(dd, na.rm=TRUE)))
axis(side=1, at=time, labels=time,
tick=FALSE, line=1, cex=0.6)
polygon(mm, poly1a, col=my4cols[1], border=NA)
polygon(mm, bb, col=my4cols[2], border=NA)
polygon(mm, cc, col=my4cols[3], border=NA)
polygon(mm, dd, col=my4cols[4], border=NA)
legend(x="topleft", fill=my4cols,
legend=my4labels,
border=FALSE, bty="n", cex=0.75)
}
polygonFun(time= comp$week,
poly1= comp$iliStudents,
poly2= comp$iliTeachers,
poly3= comp$suspectStudents,
poly4= comp$suspectTeachers)