-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfragstat_class_plots.R
180 lines (140 loc) · 7.19 KB
/
fragstat_class_plots.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
install.packages("viridis")
install.packages("lemon")
library(ggplot2)
library(dplyr)
library(viridis)
library(lemon)
working.dir <- dirname(rstudioapi::getActiveDocumentContext()$path)
data_dir <- paste(working.dir, "Data", sep="/")
raster_dir <- paste(working.dir, "Raster_Class", sep="/")
setwd(working.dir)
frag_res_class <- read.csv("C:/Users/kaitl/Documents/Kaitlin's Stuff/Dissertation/analysis-kaitlin-lobster/output/fragstats_class_results.csv")
head(frag_res_class)
frag_class_summary <- frag_res_class %>%
group_by(Year, Window, CID) %>%
summarise_at(vars("No_Patches", "Mean_Area", "Mean_PAR", "Mean_Div"), list(mean=mean, sd=sd, se = ~sd(.)/sqrt(20))) %>%
mutate(Year=as.factor(Year))
##############################################
# Mean number of patches #
##############################################
# New facet label names for window
window.labs <- c("2010 Neighbourhood Window", "2016 Neighbourhood Window", "2019 Neighbourhood Window")
names(window.labs) <- c("2010", "2016", "2019")
# New facet label names for CID
CID.labs <- c("One year present", "Two years present", "Three years present")
names(CID.labs) <- c("1", "2", "3")
mean_patch_no_plot <- ggplot(frag_class_summary)+
geom_bar(aes(x=Year, y=No_Patches_mean, fill=Year), stat="Identity")+
geom_errorbar(aes(x=Year, ymin=No_Patches_mean-No_Patches_se, ymax=No_Patches_mean+No_Patches_se), width=.2,
position=position_dodge(.9), colour="gray23")+
facet_rep_grid(Window~CID,
labeller = labeller(Window = window.labs, CID = CID.labs))+
scale_fill_manual("Year", values=c("aquamarine4", "slategray1", "darkseagreen3"))+
theme_minimal()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(color="gray57"),
strip.text.x = element_text(color = "gray57"),
strip.text.y = element_text(color = "gray57"),
axis.text.x = element_text(color = "gray57"),
axis.text.y = element_text(color = "gray57"),
axis.title = element_text(color = "gray57"),
axis.title.y = element_text(vjust = +4.75),
axis.title.x = element_text(vjust = -2.25),
line = element_line(color="gray23"),
plot.margin = margin(0.5,0.5,0.5,0.5, "cm"))+
labs(y="Mean Number of Patches")
mean_patch_no_plot
##############################################
# Mean area of patches #
##############################################
# New facet label names for window
window.labs <- c("2010 Neighbourhood Window", "2016 Neighbourhood Window", "2019 Neighbourhood Window")
names(window.labs) <- c("2010", "2016", "2019")
# New facet label names for CID
CID.labs <- c("One year present", "Two years present", "Three years present")
names(CID.labs) <- c("1", "2", "3")
Mean_Area_plot <- ggplot(frag_class_summary)+
geom_bar(aes(x=Year, y=Mean_Area_mean, fill=Year), stat="Identity")+
geom_errorbar(aes(x=Year, ymin=Mean_Area_mean-Mean_Area_se, ymax=Mean_Area_mean+Mean_Area_se), width=.2,
position=position_dodge(.9), colour="gray23")+
facet_rep_grid(Window~CID,
labeller = labeller(Window = window.labs, CID = CID.labs))+
scale_fill_manual("Year", values=c("aquamarine4", "slategray1", "darkseagreen3"))+
theme_minimal()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(color="gray57"),
strip.text.x = element_text(color = "gray57"),
strip.text.y = element_text(color = "gray57"),
axis.text.x = element_text(color = "gray57"),
axis.text.y = element_text(color = "gray57"),
axis.title = element_text(color = "gray57"),
axis.title.y = element_text(vjust = +4.75),
axis.title.x = element_text(vjust = -2.25),
line = element_line(color="gray23"),
plot.margin = margin(0.5,0.5,0.5,0.5, "cm"))+
labs(y="Mean Area of Patches")
Mean_Area_plot
##############################################################
# Mean perimeter area ratio of patches #
##############################################################
# New facet label names for window
window.labs <- c("2010 Neighbourhood Window", "2016 Neighbourhood Window", "2019 Neighbourhood Window")
names(window.labs) <- c("2010", "2016", "2019")
# New facet label names for CID
CID.labs <- c("One year present", "Two years present", "Three years present")
names(CID.labs) <- c("1", "2", "3")
Mean_PAR_plot <- ggplot(frag_class_summary)+
geom_bar(aes(x=Year, y=Mean_PAR_mean, fill=Year), stat="Identity")+
geom_errorbar(aes(x=Year, ymin=Mean_PAR_mean-Mean_PAR_se, ymax=Mean_PAR_mean+Mean_PAR_se), width=.2,
position=position_dodge(.9), colour="gray23")+
facet_rep_grid(Window~CID,
labeller = labeller(Window = window.labs, CID = CID.labs))+
scale_fill_manual("Year", values=c("aquamarine4", "slategray1", "darkseagreen3"))+
theme_minimal()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(color="gray57"),
strip.text.x = element_text(color = "gray57"),
strip.text.y = element_text(color = "gray57"),
axis.text.x = element_text(color = "gray57"),
axis.text.y = element_text(color = "gray57"),
axis.title = element_text(color = "gray57"),
axis.title.y = element_text(vjust = +4.75),
axis.title.x = element_text(vjust = -2.25),
line = element_line(color="gray23"),
plot.margin = margin(0.5,0.5,0.5,0.5, "cm"))+
labs(y="Mean Perimeter Area Ratio of Patches")
Mean_PAR_plot
#################################################
# Mean Landscape Division #
#################################################
# New facet label names for window
window.labs <- c("2010 Neighbourhood Window", "2016 Neighbourhood Window", "2019 Neighbourhood Window")
names(window.labs) <- c("2010", "2016", "2019")
# New facet label names for CID
CID.labs <- c("One year present", "Two years present", "Three years present")
names(CID.labs) <- c("1", "2", "3")
Mean_DIV_plot <- ggplot(frag_class_summary)+
geom_bar(aes(x=Year, y=Mean_Div_mean, fill=Year), stat="Identity")+
geom_errorbar(aes(x=Year, ymin=Mean_Div_mean-Mean_Div_se, ymax=Mean_Div_mean+Mean_Div_se), width=.2,
position=position_dodge(.9), colour="gray23")+
facet_rep_grid(Window~CID,
labeller = labeller(Window = window.labs, CID = CID.labs))+
scale_fill_manual("Year", values=c("aquamarine4", "slategray1", "darkseagreen3"))+
theme_minimal()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(color="gray57"),
strip.text.x = element_text(color = "gray57"),
strip.text.y = element_text(color = "gray57"),
axis.text.x = element_text(color = "gray57"),
axis.text.y = element_text(color = "gray57"),
axis.title = element_text(color = "gray57"),
axis.title.y = element_text(vjust = +4.75),
axis.title.x = element_text(vjust = -2.25),
line = element_line(color="gray23"),
plot.margin = margin(0.5,0.5,0.5,0.5, "cm"))+
labs(y="Mean Probability of Landscape Division")
Mean_DIV_plot