-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph_density.R
69 lines (57 loc) · 2.61 KB
/
graph_density.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
library(ggplot2)
library(gridExtra)
library(dplyr)
library(tidyr)
obs <- read.csv("Data/result_table.csv", header = T)
dens_plot <- function(master_table, yr){
table_1y <- filter(master_table, year == yr, box == 1 )%>%
select("box","month", "pollen","bird")%>%
mutate(freq_poll = pollen/sum(pollen)) %>%
mutate(freq_bird = bird/sum(bird)) %>%
gather(species, count, freq_poll:freq_bird)
table_2y <- filter(master_table, year == yr, box ==2)%>%
select("box","month", "pollen","bird")%>%
mutate(freq_poll = pollen/sum(pollen)) %>%
mutate(freq_bird = bird/sum(bird)) %>%
gather(species, count, freq_poll:freq_bird)
table_3y <- filter(master_table, year == yr, box ==3 )%>%
select("box","month", "pollen","bird")%>%
mutate(freq_poll = pollen/sum(pollen)) %>%
mutate(freq_bird = bird/sum(bird)) %>%
gather(species, count, freq_poll:freq_bird)
p1 <- ggplot(table_1y, aes(x= month, y = count, color = species, fill= species))+
ylim(0,1) +
geom_area(alpha=0.4)+
theme_bw()+
theme(panel.grid.major = element_blank())+
scale_x_continuous("months", breaks=1:12 , labels=c("J", "F","M","A","M","J","JL","A","S","O","N","D"))+
xlab("Month")+
ylab("Observations") +
scale_fill_manual(values = c("red","green"), labels=c("Bird", "Plant")) +
scale_color_manual(values = c("darkred","darkgreen"), guide=F) +
ggtitle("South")
p2 <- ggplot(table_2y, aes(x= month, y = count, color = species, fill= species))+
geom_area(alpha=0.4)+
ylim(0,1) +
theme_bw()+
theme(panel.grid.major = element_blank())+
scale_x_continuous("months", breaks=1:12 , labels=c("J", "F","M","A","M","J","JL","A","S","O","N","D"))+
xlab("Month")+
ylab("Observations") +
scale_fill_manual(values = c("red","green"), labels=c("Bird", "Plant")) +
scale_color_manual(values = c("darkred","darkgreen"), guide =F) +
ggtitle("Mid-East")
p3 <- ggplot(table_3y, aes(x= month, y = count, color = species, fill= species))+
ylim(0,1) +
geom_area(alpha=0.4)+
theme_bw()+
theme(panel.grid.major = element_blank())+
scale_x_continuous("months", breaks=1:12 , labels=c("J", "F","M","A","M","J","JL","A","S","O","N","D"))+
xlab("Month")+
ylab("Observations") +
scale_fill_manual(values = c("red","green"), labels=c("Bird", "Plant")) +
scale_color_manual(values = c("darkred","darkgreen"), guide=F) +
ggtitle("Northeast")
plot_boxes <- grid.arrange(p1, p2, p3, top=as.character(yr))
return(plot_boxes)
}