-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plots for Paper.R
138 lines (118 loc) · 4.76 KB
/
Plots for Paper.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Plots for paper
fd$temp %>% quantile(c(0.05,0.95))
fd$log_pred %>% quantile(c(0.05,0.95))
fd$log_prey %>% quantile(c(0.05,0.95))
fd$ratio %>% quantile(c(0.05,0.95))
fd.ppmr$ppmr %>% quantile(c(0.05,0.95))
colors = c("#2C409C","#E5AE29") #http://colorschemedesigner.com/csd-3.5/#3S21TqgsHP7BA
my_theme <- theme(plot.title = element_text(size = 20, face = "italic"),
axis.title = element_text(size = 18),
axis.text = element_text(size = 14),
legend.position = c(0.9,0.2),
legend.title = element_text(size = 21),
legend.text = element_text(size = 20),
legend.background = element_blank())
( # Plot 1A:
# Temperature * Pred Size Interaction Effect
plot_1a <-
plot_model(best.model.a.1, type = "pred",
terms = c("temp [10,27]","log_pred [-2,10]"),colors = colors, alpha = 0.3) +
ggtitle("A")+
geom_line(size = 1.4)+
theme_classic()+
xlab("Temperature (degrees Celsius)")+
ylab("Space Clearance Rate (log transformed)")+
my_theme
)
(
plot_1b_left <-
plot_model(best.model.a.1, type = "pred",
terms = c("log_prey [-8,5]","log_pred [-2,10]","aspect_ratio [1.14]"),colors = colors, alpha = 0.3) +
ggtitle(str_glue("B\nAspect Ratio = 1.14 (Sedentary)"))+
geom_line(size = 1.4)+
theme_classic()+
scale_y_continuous(limits = c(-5.5,5.5),breaks = seq(-3,3,3))+
xlab("Prey Size (log transformed)")+
ylab("Space Clearance Rate (log transformed)")+
my_theme + theme(legend.position = "none")
)
(
plot_1b_right <-
plot_model(best.model.a.1, type = "pred",
terms = c("log_prey [-8,5]","log_pred [-2,10]","aspect_ratio [2.6]"),colors = colors, alpha = 0.3) +
ggtitle("\nAspect Ratio = 2.6 (Active)")+
geom_line(size = 1.4)+
theme_classic()+
scale_y_continuous(limits = c(-5.5,5.5),breaks = seq(-3,3,3))+
xlab("Predator Size (log transformed)")+
ylab("Space Clearance Rate (log transformed)")+
my_theme + theme(legend.position = "none",axis.title.y = element_blank())
)
fig1 <- ggpubr::ggarrange(plot_1a,
ggpubr::ggarrange(plot_1b_left,plot_1b_right,ncol = 2),
ncol = 1)
#ggsave(fig1,"fig1.tiff",width = 1081,height = 901)
(
plot_2a <-
plot_model(best.model.h.1, type = "pred",
terms = c("temp [10,27]","log_pred [-2,10]"),colors = colors, alpha = 0.3) +
ggtitle("A")+
geom_line(size = 1.4)+
theme_classic()+
xlab("Temperature (degrees Celsius)")+
ylab("Handling Time (log transformed)")+
my_theme+theme(legend.position = c(0.9,0.9))
)
(
plot_2b_left <-
plot_model(best.model.h.1, type = "pred",
terms = c("log_prey [-8,5]","temp [10,27]","aspect_ratio [1.14]"),colors = colors, alpha = 0.3) +
ggtitle(str_glue("B\nAspect Ratio = 1.14 (Sedentary)"))+
geom_line(size = 1.4)+
theme_classic()+
scale_y_continuous(limits = c(-19,-1))+
xlab("Prey Size (log transformed)")+
ylab("Handling Time (log transformed)")+
my_theme + theme(legend.position = c(0.1,0.8))
)
(
plot_2b_right <-
plot_model(best.model.h.1, type = "pred",
terms = c("log_prey [-8,5]","temp [10,27]","aspect_ratio [2.6]"),colors = colors, alpha = 0.3) +
ggtitle("\nAspect Ratio = 2.6 (Active)")+
geom_line(size = 1.4)+
theme_classic()+
scale_y_continuous(limits = c(-19,-1))+
xlab("Prey Size (log transformed)")+
ylab("Handling Time (log transformed)")+
my_theme + theme(legend.position = "none",axis.title.y = element_blank())
)
fig2 <- ggpubr::ggarrange(plot_2a,
ggpubr::ggarrange(plot_2b_left,plot_2b_right,ncol = 2),
ncol = 1)
(
plot_s1a <- plot_model(best.model.a.1, type = "pred",
terms = c("temp [10,27]","alien"),colors = colors, alpha = 0.3) +
ggtitle("A")+
geom_line(size = 1.4)+
theme_classic()+
xlab("Temperature (degrees Celsius)")+
ylab("Space Clearance Rate (log transformed)")+
my_theme + theme(legend.direction = "horizontal",legend.position = c(0.9,0.1))
)
(
plot_s1b <- tibble(a1 = result.a,
a.no.alien = result.no.alien) %>%
gather(key = model,value = RMSE) %>%
ggplot()+
aes(x = model, y = RMSE,fill = model)+
geom_violin()+
stat_summary(geom = "point",fun.data = "mean_se")+
stat_summary(geom = "errorbar", fun.data = "mean_se")+
theme_classic()+scale_fill_manual(values = colors)+
my_theme+theme(axis.title.x = element_blank(),legend.position = "none")+
scale_x_discrete(breaks = c("a.no.alien","a1"),
labels = c("Model without alien", "Model with alien"))+
ggtitle("B")
)
fig1s <- ggpubr::ggarrange(plot_s1a,plot_s1b,ncol = 1)