-
Notifications
You must be signed in to change notification settings - Fork 2
/
Visualization_FeatureAnal.R
401 lines (300 loc) · 17.6 KB
/
Visualization_FeatureAnal.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
"
@author: Zsofia Koma, UvA
Aim: Analyse the results of the classification - feature importance and response curves
"
library(randomForest)
library(caret)
library(ggplot2)
library(gridExtra)
library(ggrepel)
library(reshape2)
#source("D:/Koma/GitHub/myPhD_escience_analysis/Paper1_inR_v2/Function_Classification.R")
source("D:/GitHub/eEcoLiDAR/myPhD_escience_analysis/Paper1_inR_v2/Function_Classification.R")
# Set global variables
#setwd("D:/Koma/Paper1_v2/Run4_2019April/")
setwd("D:/Sync/_Amsterdam/02_Paper1_ReedbedStructure_onlyALS/3_Dataprocessing/Results_05April/")
# Import
featuretable_l1=read.csv("featuretable_level1_b2o5.csv")
featuretable_l2=read.csv("featuretable_level2_b2o5.csv")
featuretable_l3=read.csv("featuretable_level3_b2o5.csv")
featuretable_l1_foranal=read.csv("featuretable_b2o5_wgr_whgr.csv")
featuretable_l1_foranal=featuretable_l1_foranal[featuretable_l1_foranal$layer==2,]
featuretable_l1_a=featuretable_l1_foranal[ ,c(1:26)]
featuretable_l1_b=featuretable_l1_foranal[ ,c(27:52)]
# Pre-process - rename coloumns, add feature classes
names(featuretable_l1) <- c("C_puls","C_can","3S_curv","3S_lin","S_plan","3S_sph","3S_ani","VV_sd","VV_var","VV_skew","VV_kurt","VV_cr","VV_vdr","VV_simp","VV_shan","HV_rough","HV_tpi","HV_tri",
"HV_sd","HV_var","H_max","H_mean","H_med","H_25p","H_75p","H_90p","layer")
names(featuretable_l2) <- c("C_puls","C_can","3S_curv","3S_lin","S_plan","3S_sph","3S_ani","VV_sd","VV_var","VV_skew","VV_kurt","VV_cr","VV_vdr","VV_simp","VV_shan","HV_rough","HV_tpi","HV_tri",
"HV_sd","HV_var","H_max","H_mean","H_med","H_25p","H_75p","H_90p","layer")
names(featuretable_l3) <- c("C_puls","C_can","3S_curv","3S_lin","S_plan","3S_sph","3S_ani","VV_sd","VV_var","VV_skew","VV_kurt","VV_cr","VV_vdr","VV_simp","VV_shan","HV_rough","HV_tpi","HV_tri",
"HV_sd","HV_var","H_max","H_mean","H_med","H_25p","H_75p","H_90p","layer")
names(featuretable_l1_a) <- c("C_puls","C_can","3S_curv","3S_lin","S_plan","3S_sph","3S_ani","VV_sd","VV_var","VV_skew","VV_kurt","VV_cr","VV_vdr","VV_simp","VV_shan","HV_rough","HV_tpi","HV_tri",
"HV_sd","HV_var","H_max","H_mean","H_med","H_25p","H_75p","H_90p")
names(featuretable_l1_b) <- c("C_puls","C_can","3S_curv","3S_lin","S_plan","3S_sph","3S_ani","VV_sd","VV_var","VV_skew","VV_kurt","VV_cr","VV_vdr","VV_simp","VV_shan","HV_rough","HV_tpi","HV_tri",
"HV_sd","HV_var","H_max","H_mean","H_med","H_25p","H_75p","H_90p")
# App.1.. : boxplots ground whout ground
vegetation_wgr=featuretable_l1_a[ ,c(1:2)]
vegetation_whgr=featuretable_l1_b[,c(1:2)]
vegetation_wgr_f=melt(vegetation_wgr)
vegetation_whgr_f=melt(vegetation_whgr)
vegetation_wgr_f$class <-1
vegetation_whgr_f$class <-2
vegetation_var=rbind(vegetation_wgr_f,vegetation_whgr_f)
p1=ggplot(data = vegetation_var, aes(x=variable, y=value,fill=factor(class))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "coral1", "2" = "cyan2"),name="Calculation type",labels=c("With ground","Without ground")) +
xlab("Feature class: Cover") + ylab("Ratio[%]") +
theme_bw(base_size = 17)
vegetation_wgr_h=featuretable_l1_a[ ,c(3:7)]
vegetation_whgr_h=featuretable_l1_b[,c(3:7)]
vegetation_wgr_f_h=melt(vegetation_wgr_h)
vegetation_whgr_f_h=melt(vegetation_whgr_h)
vegetation_wgr_f_h$class <-1
vegetation_whgr_f_h$class <-2
vegetation_var_h=rbind(vegetation_wgr_f_h,vegetation_whgr_f_h)
p2=ggplot(data = vegetation_var_h, aes(x=variable, y=value,fill=factor(class))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "coral1", "2" = "cyan2"),name="Calculation type",labels=c("With ground","Without ground")) +
xlab("Feature class: 3D shape") + ylab("Ratio between eigenvalues") +
theme_bw(base_size = 17)
vegetation_wgr_h=featuretable_l1_a[ ,c(8:11)]
vegetation_whgr_h=featuretable_l1_b[,c(8:11)]
vegetation_wgr_f_h=melt(vegetation_wgr_h)
vegetation_whgr_f_h=melt(vegetation_whgr_h)
vegetation_wgr_f_h$class <-1
vegetation_whgr_f_h$class <-2
vegetation_var_h=rbind(vegetation_wgr_f_h,vegetation_whgr_f_h)
p3a=ggplot(data = vegetation_var_h, aes(x=variable, y=value,fill=factor(class))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "coral1", "2" = "cyan2"),name="Calculation type",labels=c("With ground","Without ground")) +
xlab("Feature class: Vertical variability") + ylab("Variability [m]") +
theme_bw(base_size = 17)
vegetation_wgr_h=featuretable_l1_a[ ,c(12:15)]
vegetation_whgr_h=featuretable_l1_b[,c(12:15)]
vegetation_wgr_f_h=melt(vegetation_wgr_h)
vegetation_whgr_f_h=melt(vegetation_whgr_h)
vegetation_wgr_f_h$class <-1
vegetation_whgr_f_h$class <-2
vegetation_var_h=rbind(vegetation_wgr_f_h,vegetation_whgr_f_h)
p3b=ggplot(data = vegetation_var_h, aes(x=variable, y=value,fill=factor(class))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "coral1", "2" = "cyan2"),name="Calculation type",labels=c("With ground","Without ground")) +
xlab("Feature class: Vertical variability") + ylab("Variability [m]") +
theme_bw(base_size = 17)
vegetation_wgr_h=featuretable_l1_a[ ,c(16:20)]
vegetation_whgr_h=featuretable_l1_b[,c(16:20)]
vegetation_wgr_f_h=melt(vegetation_wgr_h)
vegetation_whgr_f_h=melt(vegetation_whgr_h)
vegetation_wgr_f_h$class <-1
vegetation_whgr_f_h$class <-2
vegetation_var_h=rbind(vegetation_wgr_f_h,vegetation_whgr_f_h)
p4=ggplot(data = vegetation_var_h, aes(x=variable, y=value,fill=factor(class))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "coral1", "2" = "cyan2"),name="Calculation type",labels=c("With ground","Without ground")) +
xlab("Feature class: Horizontal variability") + ylab("Variability [m]") +
theme_bw(base_size = 17)
vegetation_wgr_h=featuretable_l1_a[ ,c(21:26)]
vegetation_whgr_h=featuretable_l1_b[,c(21:26)]
vegetation_wgr_f_h=melt(vegetation_wgr_h)
vegetation_whgr_f_h=melt(vegetation_whgr_h)
vegetation_wgr_f_h$class <-1
vegetation_whgr_f_h$class <-2
vegetation_var_h=rbind(vegetation_wgr_f_h,vegetation_whgr_f_h)
p5=ggplot(data = vegetation_var_h, aes(x=variable, y=value,fill=factor(class))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "coral1", "2" = "cyan2"),name="Calculation type",labels=c("With ground","Without ground")) +
xlab("Feature class: Height") + ylab("Height [m]") +
theme_bw(base_size = 17)
p0=ggplot(data = vegetation_var, aes(x=variable, y=value,fill=factor(class))) + geom_boxplot(show.legend = TRUE)+
scale_fill_manual(values = c("1" = "coral1", "2" = "cyan2"),name="Calculation type",labels=c("With ground","Without ground")) +
xlab("Feature class: Cover") + ylab("Ratio[%]") +
theme_bw(base_size = 17)
get_legend<-function(myggplot){
tmp <- ggplot_gtable(ggplot_build(myggplot))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
return(legend)
}
legend <- get_legend(p0)
grid.arrange(
p2,
p5,
p4,
p3a,
p3b,
legend,
ncol=2,
nrow=3,
layout_matrix=rbind(c(1,2),c(3,4),c(5,6))
)
# boxplots per classes
# level1
featuretable_l1_c=featuretable_l1[ ,c(1:2,27)]
featuretable_l1_c_b=melt(featuretable_l1_c,id.vars="layer")
featuretable_l1_3s=featuretable_l1[ ,c(3:7,27)]
featuretable_l1_3s_b=melt(featuretable_l1_3s,id.vars="layer")
featuretable_l1_vva=featuretable_l1[ ,c(8:11,27)]
featuretable_l1_vva_b=melt(featuretable_l1_vva,id.vars="layer")
featuretable_l1_vvb=featuretable_l1[ ,c(12:15,27)]
featuretable_l1_vvb_b=melt(featuretable_l1_vvb,id.vars="layer")
featuretable_l1_hv=featuretable_l1[ ,c(16:20,27)]
featuretable_l1_hv_b=melt(featuretable_l1_hv,id.vars="layer")
featuretable_l1_h=featuretable_l1[ ,c(21:26,27)]
featuretable_l1_h_b=melt(featuretable_l1_h,id.vars="layer")
p11=ggplot(data = featuretable_l1_c_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgrey", "2" = "aquamarine4"),name="Level 1",labels=c("Planar surfaces","Vegetation")) +
xlab("Feature class: Cover") + ylab("Ratio [%]") +
theme_bw(base_size = 17)
p12=ggplot(data = featuretable_l1_3s_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgrey", "2" = "aquamarine4"),name="Level 1",labels=c("Planar surfaces","Vegetation")) +
xlab("Feature class: 3D shape") + ylab("Ratio of eigenvalues") +
theme_bw(base_size = 17)
p13=ggplot(data = featuretable_l1_vva_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgrey", "2" = "aquamarine4"),name="Level 1",labels=c("Planar surfaces","Vegetation")) +
xlab("Feature class: Vertical variability") + ylab("Variability [m]") +
theme_bw(base_size = 17)
p14=ggplot(data = featuretable_l1_vvb_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgrey", "2" = "aquamarine4"),name="Level 1",labels=c("Planar surfaces","Vegetation")) +
xlab("Feature class: Vertical variability") + ylab("Variability [m]") +
theme_bw(base_size = 17)
p15=ggplot(data = featuretable_l1_hv_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgrey", "2" = "aquamarine4"),name="Level 1",labels=c("Planar surfaces","Vegetation")) +
xlab("Feature class: Horizontal variability") + ylab("Variability [m]") +
theme_bw(base_size = 17) + ylim(0,10)
p16=ggplot(data = featuretable_l1_h_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgrey", "2" = "aquamarine4"),name="Level 1",labels=c("Planar surfaces","Vegetation")) +
xlab("Feature class: Height") + ylab("Height [m]") +
theme_bw(base_size = 17)
get_legend<-function(myggplot){
tmp <- ggplot_gtable(ggplot_build(myggplot))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
return(legend)
}
legend <- get_legend(p0)
grid.arrange(
p11,
p12,
p13,
p14,
p15,
p16,
ncol=3,
nrow=2,
layout_matrix=rbind(c(1,2,3),c(4,5,6))
)
# level2
featuretable_l2_c=featuretable_l2[ ,c(1:2,27)]
featuretable_l2_c_b=melt(featuretable_l2_c,id.vars="layer")
featuretable_l2_3s=featuretable_l2[ ,c(3:7,27)]
featuretable_l2_3s_b=melt(featuretable_l2_3s,id.vars="layer")
featuretable_l2_vva=featuretable_l2[ ,c(8:11,27)]
featuretable_l2_vva_b=melt(featuretable_l2_vva,id.vars="layer")
featuretable_l2_vvb=featuretable_l2[ ,c(12:15,27)]
featuretable_l2_vvb_b=melt(featuretable_l2_vvb,id.vars="layer")
featuretable_l2_hv=featuretable_l2[ ,c(16:20,27)]
featuretable_l2_hv_b=melt(featuretable_l2_hv,id.vars="layer")
featuretable_l2_h=featuretable_l2[ ,c(21:26,27)]
featuretable_l2_h_b=melt(featuretable_l2_h,id.vars="layer")
p11=ggplot(data = featuretable_l2_c_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgreen", "2" = "chartreuse", "3" = "darkorange3", "4" = "darkolivegreen3"),name="Level 2",labels=c("Forest","Grassland","Reedbed","Shrub")) +
xlab("Feature class: Cover") + ylab("Ratio [%]") +
theme_bw(base_size = 17)
p12=ggplot(data = featuretable_l2_3s_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgreen", "2" = "chartreuse", "3" = "darkorange3", "4" = "darkolivegreen3"),name="Level 2",labels=c("Forest","Grassland","Reedbed","Shrub")) +
xlab("Feature class: 3D shape") + ylab("Ratio of eigenvalues") +
theme_bw(base_size = 17)
p13=ggplot(data = featuretable_l2_vva_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgreen", "2" = "chartreuse", "3" = "darkorange3", "4" = "darkolivegreen3"),name="Level 2",labels=c("Forest","Grassland","Reedbed","Shrub")) +
xlab("Feature class: Vertical variability") + ylab("Variability [m]") +
theme_bw(base_size = 17)
p14=ggplot(data = featuretable_l2_vvb_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgreen", "2" = "chartreuse", "3" = "darkorange3", "4" = "darkolivegreen3"),name="Level 2",labels=c("Forest","Grassland","Reedbed","Shrub")) +
xlab("Feature class: Vertical variability") + ylab("Variability [m]") +
theme_bw(base_size = 17)
p15=ggplot(data = featuretable_l2_hv_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgreen", "2" = "chartreuse", "3" = "darkorange3", "4" = "darkolivegreen3"),name="Level 2",labels=c("Forest","Grassland","Reedbed","Shrub")) +
xlab("Feature class: Horizontal variability") + ylab("Variability [m]") +
theme_bw(base_size = 17) + ylim(0,10)
p16=ggplot(data = featuretable_l2_h_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgreen", "2" = "chartreuse", "3" = "darkorange3", "4" = "darkolivegreen3"),name="Level 2",labels=c("Forest","Grassland","Reedbed","Shrub")) +
xlab("Feature class: Height") + ylab("Height [m]") +
theme_bw(base_size = 17)
p00=ggplot(data = featuretable_l2_h_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = TRUE)+
scale_fill_manual(values = c("1" = "darkgreen", "2" = "chartreuse", "3" = "darkorange3", "4" = "darkolivegreen3"),name="Level 2",labels=c("Forest","Grassland","Reedbed","Shrub")) +
xlab("Feature class: Height") + ylab("Height [m]") +
theme_bw(base_size = 17)
get_legend<-function(myggplot){
tmp <- ggplot_gtable(ggplot_build(myggplot))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
return(legend)
}
legend <- get_legend(p00)
grid.arrange(
p11,
p12,
p13,
p14,
p15,
p16,
legend,
ncol=4,
nrow=2,
layout_matrix=rbind(c(1,2,3,7),c(4,5,6,7))
)
# level3
featuretable_l3_c=featuretable_l3[ ,c(1:2,27)]
featuretable_l3_c_b=melt(featuretable_l3_c,id.vars="layer")
featuretable_l3_3s=featuretable_l3[ ,c(3:7,27)]
featuretable_l3_3s_b=melt(featuretable_l3_3s,id.vars="layer")
featuretable_l3_vva=featuretable_l3[ ,c(8:11,27)]
featuretable_l3_vva_b=melt(featuretable_l3_vva,id.vars="layer")
featuretable_l3_vvb=featuretable_l3[ ,c(12:15,27)]
featuretable_l3_vvb_b=melt(featuretable_l3_vvb,id.vars="layer")
featuretable_l3_hv=featuretable_l3[ ,c(16:20,27)]
featuretable_l3_hv_b=melt(featuretable_l3_hv,id.vars="layer")
featuretable_l3_h=featuretable_l3[ ,c(21:26,27)]
featuretable_l3_h_b=melt(featuretable_l3_h,id.vars="layer")
p11=ggplot(data = featuretable_l3_c_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgoldenrod1", "2" = "darkorange", "3" = "darkorange4"),name="Level 3",labels=c("Landreed structurally poor","Landreed structurally rich","Water reed")) +
xlab("Feature class: Cover") + ylab("Ratio [%]") +
theme_bw(base_size = 17)
p12=ggplot(data = featuretable_l3_3s_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgoldenrod1", "2" = "darkorange", "3" = "darkorange4"),name="Level 3",labels=c("Landreed structurally poor","Landreed structurally rich","Water reed")) +
xlab("Feature class: 3D shape") + ylab("Ratio of eigenvalues") +
theme_bw(base_size = 17)
p13=ggplot(data = featuretable_l3_vva_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgoldenrod1", "2" = "darkorange", "3" = "darkorange4"),name="Level 3",labels=c("Landreed structurally poor","Landreed structurally rich","Water reed")) +
xlab("Feature class: Vertical variability") + ylab("Variability [m]") +
theme_bw(base_size = 17)
p14=ggplot(data = featuretable_l3_vvb_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgoldenrod1", "2" = "darkorange", "3" = "darkorange4"),name="Level 3",labels=c("Landreed structurally poor","Landreed structurally rich","Water reed")) +
xlab("Feature class: Vertical variability") + ylab("Variability [m]") +
theme_bw(base_size = 17)
p15=ggplot(data = featuretable_l3_hv_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgoldenrod1", "2" = "darkorange", "3" = "darkorange4"),name="Level 3",labels=c("Landreed structurally poor","Landreed structurally rich","Water reed")) +
xlab("Feature class: Horizontal variability") + ylab("Variability [m]") +
theme_bw(base_size = 17) + ylim(0,10)
p16=ggplot(data = featuretable_l3_h_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = FALSE)+
scale_fill_manual(values = c("1" = "darkgoldenrod1", "2" = "darkorange", "3" = "darkorange4"),name="Level 3",labels=c("Landreed structurally poor","Landreed structurally rich","Water reed")) +
xlab("Feature class: Height") + ylab("Height [m]") +
theme_bw(base_size = 17)
p00=ggplot(data = featuretable_l3_h_b, aes(x=variable, y=value,fill=factor(layer))) + geom_boxplot(show.legend = TRUE)+
scale_fill_manual(values = c("1" = "darkgoldenrod1", "2" = "darkorange", "3" = "darkorange4"),name="Level 3",labels=c("Landreed structurally poor","Landreed structurally rich","Water reed")) +
xlab("Feature class: Height") + ylab("Height [m]") +
theme_bw(base_size = 17)
get_legend<-function(myggplot){
tmp <- ggplot_gtable(ggplot_build(myggplot))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
return(legend)
}
legend <- get_legend(p00)
grid.arrange(
p11,
p12,
p13,
p14,
p15,
p16,
legend,
ncol=4,
nrow=2,
layout_matrix=rbind(c(1,2,3,7),c(4,5,6,7))
)
# Partial dependence plots