#### Set parameter #### library(ggplot2) library(ggpubr) library(readxl) library(data.table) library(reshape2) library(gridExtra) library(gtable) library(grid) library(dplyr) # Do I want to save the plots (or skip to save time) SavePlots<-TRUE # How many bootstraps? boot<-50000 # Chooses to do "LogResp", "Linear" or "LogLink" Approach<-"LogResp" #### Load data #### load(file="\\\\home.ansatt.ntnu.no/jonatanf/Documents/PhD/Chapter1/SPpartablist.r.rda") SPparam<-SPpartablist.r SPparam<-within(SPparam, rm("BLĂ…KVEITE")) ####################################################. av<-c(50*50,70*70,8100,110*110,130*130,150*150,170*170,190*190,210*210,230*230) setwd("//home.ansatt.ntnu.no/jonatanf/Documents/PhD/Chapter1/Data") # lists to facilitate loops and subsetting # Helps when loading LH data LHcolnames<-c("Species", "EM","VarM", "CVRS", "CVlambda", "GT", "RS", "lambda") # For labels in plots SpatialNames<-c("'E(M'[a,y])", "Var(M[a,y]", "lambda[y]","CV(lambda[y])", "Generation Time") ### ### ### ### ### ### ### ### ### ### ### ### ### ############. ### ### ### ### ### ### ############# ### ### ############# ### ###Life-history #### load(file="Dynlife.Rdata") PopP<-data.frame(Species=c(rep("Cod",1002) , rep("Haddock",1002), rep("Saithe",1002), rep("BeakedRedfish",1002), rep("GoldenRedfish",1002), rep("BlueWhiting",1002), rep("Capelin",1002), rep("Herring",1002))) # list of species by name # Organizing data into 1 data frame for(lh in 1:7){ AllData<-data.frame() for(sp in c(1:5,7:9)){ AllData<-rbind(AllData, data.frame(Dynlife[sp, lh, ])) } PopP<-cbind(PopP, AllData) } colnames(PopP)<-LHcolnames PopP<-PopP[,c(1,2,3,7,4,8,5,6)] PopP<-data.table(PopP) PopP$EM<-ifelse(PopP$EM> 1, 1, PopP$EM) PopP$VarM<-ifelse(PopP$VarM> 1, 1, PopP$VarM) Estim_M_AllRes<-data.frame() Estim_VM_AllRes<-data.frame() Estim_L_AllRes<-data.frame() Estim_CVL_AllRes<-data.frame() Estim_GT_AllRes<-data.frame() LinePlotsR<-list() DenPlots<-list() ######################################################### # Choose the resolution we cant to work with... #for(Res in 1:length(SPparam[[1]])){ # OR Res<-8 Main<-TRUE ######################################################### #Make 1 dataframe with both synchrony and life history parameters (because Life history has 1002 row, I randomly chose 1000) AllData<-data.frame() for(sp in c(1:8)){ #To make sure we skip halibut PopPsp<-subset(PopP, Species==unique(PopP$Species)[sp]) AllData<-rbind(data.frame(SPparam[[sp]][[Res]], PopPsp[sample(nrow(PopPsp), 1000),]),AllData) } #Make a dataframe with the means and 95 confidence intervals of each species synchrony and life history parameters dfVars<-AllData %>% group_by(Species) %>% mutate(llow= quantile(logl, 0.025)) %>% mutate(lhigh= quantile(logl, 0.975)) %>% mutate(meanl= median(logl)) %>% mutate(EMlow= quantile(EM, 0.025)) %>% mutate(EMhigh= quantile(EM, 0.975)) %>% mutate(meanEM= mean(EM)) %>% mutate(VarMlow= quantile(VarM, 0.025)) %>% mutate(VarMhigh= quantile(VarM, 0.975)) %>% mutate(meanVarM= mean(VarM)) %>% mutate(lambdalow= quantile(lambda, 0.025)) %>% mutate(lambdahigh= quantile(lambda, 0.975)) %>% mutate(meanlambda= mean(lambda)) %>% mutate(CVlambdalow= quantile(CVlambda, 0.025)) %>% mutate(CVlambdahigh= quantile(CVlambda, 0.975)) %>% mutate(meanCVlambda= mean(CVlambda)) %>% mutate(GTlow= quantile(GT, 0.025)) %>% mutate(GThigh= quantile(GT, 0.975)) %>% mutate(meanGT= mean(GT)) %>% as.data.frame() dfVar<-unique(dfVars[c(8, 16:33)]) # Time to bootstrap the model to masure thevariability in the relationship Estim_M<-matrix(nrow= boot, ncol=2) LinesX_M<-matrix(nrow= boot, ncol=2) Estim_VM<-matrix(nrow= boot, ncol=2) LinesX_VM<-matrix(nrow= boot, ncol=2) Estim_L<-matrix(nrow= boot, ncol=2) LinesX_L<-matrix(nrow= boot, ncol=2) Estim_CVL<-matrix(nrow= boot, ncol=2) LinesX_CVL<-matrix(nrow= boot, ncol=2) Estim_GT<-matrix(nrow= boot, ncol=2) LinesX_GT<-matrix(nrow= boot, ncol=2) #### Bootstrapping models #### # Chooses what synchrony parameter I want to test. logl, logitrho0 or logitrhoinf (RhoDiff?) # Bootstrapping for(i in 1:boot){ new_acdf <- AllData[c("logl", "Species")] %>% group_by(Species) %>% sample_n(1) new_lhdf <- AllData[,c("Species", "EM","VarM","lambda","CVlambda","GT")] %>% group_by(Species) %>% sample_n(1) new_df<-data.frame(data.frame(new_lhdf), data.frame(new_acdf)) Model_EM<-glm(logl ~ EM, data=new_df, family= "gaussian") Estim_M[i,]<-t(matrix(summary(Model_EM)$coefficients[,1])) LinesX_M[i,]<-c(min(new_lhdf$EM), max(new_lhdf$EM)) Model_VM<-glm(logl ~ VarM, data=new_df, family= "gaussian") Estim_VM[i,]<-t(matrix(summary(Model_VM)$coefficients[,1])) LinesX_VM[i,]<-c(min(new_lhdf$VarM), max(new_lhdf$VarM)) Model_L<-glm(logl ~ lambda, data=new_df, family= "gaussian") Estim_L[i,]<-t(matrix(summary(Model_L)$coefficients[,1])) LinesX_L[i,]<-c(min(new_lhdf$lambda), max(new_lhdf$lambda)) Model_CVL<-glm(logl ~ CVlambda, data=new_df, family= "gaussian") Estim_CVL[i,]<-t(matrix(summary(Model_CVL)$coefficients[,1])) LinesX_CVL[i,]<-c(min(new_lhdf$CVlambda), max(new_lhdf$CVlambda)) Model_GT<-glm(logl ~ GT, data=new_df, family= "gaussian") Estim_GT[i,]<-t(matrix(summary(Model_GT)$coefficients[,1])) LinesX_GT[i,]<-c(min(new_lhdf$GT), max(new_lhdf$GT)) print(i) } print("models run") ### ### # # # # # # # # # # # M #### # Make 2 matrices. One with ranges for all predictor variables from bootstrapping. One for the range of the mean of the predictor variable Xstandard<-matrix(seq(min(dfVar$EMlow), max(dfVar$EMhigh),length.out = 50)) Ystandard<-matrix(nrow=boot, ncol= 50) X<-matrix(nrow=boot, ncol= 50) Y<-matrix(nrow=boot, ncol= 50) for(i in 1:boot){ Ystandard[i,]<-Estim_M[i,1] + (Xstandard * Estim_M[i,2]) Y[i,]<-Estim_M[i,1]+ seq(LinesX_M[i,1], LinesX_M[i,2], length.out = 50) * Estim_M[i,2] ## This I would need to do when I am plotting all lines. but not for the ribbon. X[i,]<-seq(LinesX_M[i,1], LinesX_M[i,2], length.out = 50) } # Get the 95CI of the Y variable at each X (within the range of the means of the predictor variable) YCI<-apply(Ystandard, 2, function(Ystandard) quantile(Ystandard, probs = c(0,0.025, 0.5, 0.975, 1), names = TRUE)) YCI<-data.frame(t(YCI)) YCI$X<-Xstandard # Creating lines for all the models made in the bootstrapping Y<-data.frame(t(Y)) dfY<-melt(Y) X<-data.frame(t(X)) dfX<-melt(X) dfBoot<-cbind(dfY, dfX$value) colnames(dfBoot)<-c("BootN", "Scaling", "LH") dfVar$LongLine<-ifelse(dfVar$lhigh>ifelse(Main==TRUE, log(600), max(YCI$X97.5.)),"dashed", "solid") dfBoot$Scaling<-exp(dfBoot$Scaling) YCI[,1:5]<-exp(YCI[,1:5]) #### ...lines #### ModM<-summary(glm(meanl ~ meanEM, data=dfVar, family= "gaussian")) Neg<-prop.table(table(ifelse(Estim_M[,2]<0, "Neg.", "Pos.")))[1] #plotting all Mlines<-ggplot(dfVar, aes(meanEM, exp(meanl)))+ geom_ribbon(data=YCI, aes(ymin = X2.5., ymax = X97.5., x= X),fill = "grey80", alpha=0.7,inherit.aes = FALSE) + geom_line(data=YCI, aes(y= X50., x = X), inherit.aes = FALSE)+ geom_errorbar(aes(x= meanEM, ymin =exp(llow), ymax = exp(lhigh), width=0),color="grey40", linetype=dfVar$LongLine)+ geom_errorbarh(aes(y= exp(meanl), xmin =EMlow, xmax = EMhigh, height=0),alpha=0.5,color="grey40")+ geom_point(col= "black", alpha= 0.7)+ theme_classic()+ labs(x = expression(E(italic(M["a,t"]))), y = expression(italic(l)["r"](km)))+ coord_cartesian(ylim = c(0, ifelse(Main==TRUE, 580, max(YCI$X97.5.)))) + #annotate("text", x=Inf, y = Inf, label = paste("P(beta[1]<0)== ", round(Neg, 3)), parse=TRUE,vjust=2, hjust=1)+ annotate("text", x=Inf, y = Inf,label = "d)",vjust=1, hjust=1)+ theme(axis.ticks.length=unit(-0.10, "cm"), axis.text.y = element_text(margin=margin(0,4,0,0,"pt"),colour="grey20",face="plain"), axis.text.x = element_text(margin=margin(5,0,0,0,"pt"),colour="grey20",face="plain")) setwd("\\\\home.ansatt.ntnu.no/jonatanf/Documents/PhD/Chapter1/Figures/NP.BOOT.Synch_LHist.Resolutions-r/LogResponse/") if(SavePlots){ggsave(Mlines, file= paste("MBoot_lines", av[Res],".png", sep=""), width = 4, height =3, dpi= 300)} #### Var M #### Xstandard<-matrix(seq(min(dfVar$VarMlow), max(dfVar$VarMhigh),length.out = 50)) Y<-matrix(nrow=boot, ncol= 50) Ystandard<-matrix(nrow=boot, ncol= 50) X<-matrix(nrow=boot, ncol= 50) for(i in 1:boot){ Y[i,]<-Estim_VM[i,1]+ seq(LinesX_VM[i,1], LinesX_VM[i,2], length.out = 50) * Estim_VM[i,2] Ystandard[i,]<-Estim_VM[i,1]+ Xstandard * Estim_VM[i,2] X[i,]<-seq(LinesX_VM[i,1], LinesX_VM[i,2], length.out = 50) } YCI<-apply(Ystandard, 2, function(Ystandard) quantile(Ystandard, probs = c(0,0.025, 0.5, 0.975, 1), names = TRUE)) YCI<-data.frame(t(YCI)) YCI$X<-Xstandard Y<-data.frame(t(Y)) dfY<-melt(Y) X<-data.frame(t(X)) dfX<-melt(X) dfBoot<-cbind(dfY, dfX$value) colnames(dfBoot)<-c("BootN", "Scaling", "LH") dfVar$LongLine<-ifelse(dfVar$lhigh>ifelse(Main==TRUE, log(600), max(YCI$X97.5.)),"dashed", "solid") dfBoot$Scaling<-exp(dfBoot$Scaling) YCI[,1:5]<-exp(YCI[,1:5]) #### ...lines #### ModVM<-summary(glm(meanl ~ meanVarM, data=dfVar, family= "gaussian")) Neg<-prop.table(table(ifelse(Estim_VM[,2]<0, "Neg.", "Pos.")))[1] VarMlines<-ggplot(dfVar, aes(meanVarM, exp(meanl)))+ geom_ribbon(data=YCI, aes(ymin = X2.5., ymax = X97.5., x= X),fill = "grey80", alpha=0.7,inherit.aes = FALSE) + geom_line(data=YCI, aes(y= X50., x = X), inherit.aes = FALSE)+ geom_errorbar(aes(x= meanVarM, ymin =exp(llow), ymax = exp(lhigh), width=0),color="grey40", linetype=dfVar$LongLine)+ geom_errorbarh(aes(y= exp(meanl), xmin =VarMlow, xmax = VarMhigh, height=0),alpha=0.5,color="grey40")+ geom_point(col= "black", alpha= 0.7)+ theme_classic()+ labs(x = expression(Var(italic(M["a,t"]))), y = expression(italic(l)["r"](km)))+ coord_cartesian(ylim = c(0, ifelse(Main==TRUE, 580, max(YCI$X97.5.)))) + #annotate("text", x=Inf, y = Inf, label = paste("P(beta[1]<0)== ", round(Neg, 3)), parse=TRUE,vjust=2, hjust=1)+ annotate("text", x=Inf, y = Inf,label = "e)",vjust=1, hjust=1)+ theme(axis.ticks.length=unit(-0.10, "cm"), axis.text.y = element_text(margin=margin(0,4,0,0,"pt"),colour="grey20",face="plain"), axis.text.x = element_text(margin=margin(5,0,0,0,"pt"),colour="grey20",face="plain")) print(paste("P(beta[1]>0)== ", round(Neg, 3))) if(SavePlots){ggsave(VarMlines, file= paste("VarMBoot_lines",av[Res],".png", sep=""), width = 4, height =3, dpi= 300) } ##### Lambda #### Xstandard<-matrix(seq(min(dfVar$lambdalow), max(dfVar$lambdahigh),length.out = 50)) Y<-matrix(nrow=boot, ncol= 50) Ystandard<-matrix(nrow=boot, ncol= 50) X<-matrix(nrow=boot, ncol= 50) for(i in 1:boot){ Y[i,]<-Estim_L[i,1]+ seq(LinesX_L[i,1], LinesX_L[i,2], length.out = 50) * Estim_L[i,2] Ystandard[i,]<-Estim_L[i,1]+ Xstandard * Estim_L[i,2] X[i,]<-seq(LinesX_L[i,1], LinesX_L[i,2], length.out = 50) } YCI<-apply(Ystandard, 2, function(Ystandard) quantile(Ystandard, probs = c(0,0.025, 0.5, 0.975, 1), names = TRUE)) YCI<-data.frame(t(YCI)) YCI$X<-Xstandard Y<-data.frame(t(Y)) dfY<-melt(Y) X<-data.frame(t(X)) dfX<-melt(X) dfBoot<-cbind(dfY, dfX$value) colnames(dfBoot)<-c("BootN", "Scaling", "LH") dfVar$LongLine<-ifelse(dfVar$lhigh>ifelse(Main==TRUE, log(600), max(YCI$X97.5.)),"dashed", "solid") dfBoot$Scaling<-exp(dfBoot$Scaling) YCI[,1:5]<-exp(YCI[,1:5]) #### ...lines #### ModL<-summary(glm(meanl ~ meanlambda, data=dfVar, family= "gaussian")) Neg<-prop.table(table(ifelse(Estim_L[,2]<0, "Neg.", "Pos.")))[1] lamblines<-ggplot(dfVar, aes(meanlambda, exp(meanl)))+ geom_ribbon(data=YCI, aes(ymin = X2.5., ymax = X97.5., x= X),fill = "grey80", alpha=0.7,inherit.aes = FALSE) + geom_line(data=YCI, aes(y= X50., x = X), inherit.aes = FALSE)+ geom_errorbar(aes(x= meanlambda, ymin =exp(llow), ymax = exp(lhigh), width=0),color="grey40", linetype=dfVar$LongLine)+ geom_errorbarh(aes(y= exp(meanl), xmin =lambdalow, xmax = lambdahigh, height=0),alpha=0.5,color="grey40")+ geom_point(col= "black", alpha= 0.7)+ theme_classic()+ labs(x = expression(italic(lambda[t])), y = expression(italic(l)["r"](km)))+ coord_cartesian(ylim = c(0, ifelse(Main==TRUE, 580, max(YCI$X97.5.)))) + #annotate("text", x=Inf, y = Inf, label = paste("P(beta[1]<0)== ", round(Neg, 3)), parse=TRUE,vjust=2, hjust=1)+ annotate("text", x=Inf, y = Inf,label = "b)",vjust=1, hjust=1)+ theme(axis.ticks.length=unit(-0.10, "cm"), axis.text.y = element_text(margin=margin(0,4,0,0,"pt"),colour="grey20",face="plain"), axis.text.x = element_text(margin=margin(5,0,0,0,"pt"),colour="grey20",face="plain")) print(paste("P(beta[1]>0)== ", round(Neg, 3))) if(SavePlots){ggsave(lamblines, file= paste("lambBoot_lines",av[Res],".png", sep=""), width = 4, height =3, dpi= 300) } ##### CV lambda #### Xstandard<-matrix(seq(min(dfVar$CVlambdalow), max(dfVar$CVlambdahigh),length.out = 50)) Y<-matrix(nrow=boot, ncol= 50) Ystandard<-matrix(nrow=boot, ncol= 50) X<-matrix(nrow=boot, ncol= 50) for(i in 1:boot){ Y[i,]<-Estim_CVL[i,1]+ seq(LinesX_CVL[i,1], LinesX_CVL[i,2], length.out = 50) * Estim_CVL[i,2] Ystandard[i,]<-Estim_CVL[i,1]+ Xstandard * Estim_CVL[i,2] X[i,]<-seq(LinesX_CVL[i,1], LinesX_CVL[i,2], length.out = 50) } YCI<-apply(Ystandard, 2, function(Ystandard) quantile(Ystandard, probs = c(0,0.025, 0.5, 0.975, 1), names = TRUE)) YCI<-data.frame(t(YCI)) YCI$X<-Xstandard Y<-data.frame(t(Y)) dfY<-melt(Y) X<-data.frame(t(X)) dfX<-melt(X) dfBoot<-cbind(dfY, dfX$value) colnames(dfBoot)<-c("BootN", "Scaling", "LH") dfVar$LongLine<-ifelse(dfVar$lhigh>ifelse(Main==TRUE, log(600), max(YCI$X97.5.)),"dashed", "solid") dfBoot$Scaling<-exp(dfBoot$Scaling) YCI[,1:5]<-exp(YCI[,1:5]) #### ...lines #### ModCVL<-summary(glm(meanl ~ meanCVlambda, data=dfVar, family= "gaussian")) CVlamblines<-ggplot(dfVar, aes(meanCVlambda, exp(meanl)))+ geom_ribbon(data=YCI, aes(ymin = X2.5., ymax = X97.5., x= X),fill = "grey80", alpha=0.7,inherit.aes = FALSE) + geom_line(data=YCI, aes(y= X50., x = X), inherit.aes = FALSE)+ geom_errorbar(aes(x= meanCVlambda, ymin =exp(llow), ymax = exp(lhigh), width=0),color="grey40", linetype=dfVar$LongLine)+ geom_errorbarh(aes(y= exp(meanl), xmin =CVlambdalow, xmax = CVlambdahigh, height=0),alpha=0.5,color="grey40")+ geom_point(col= "black", alpha= 0.7)+ theme_classic()+ labs(x = expression(CV(italic(lambda[t]))), y = expression(italic(l)["r"](km)))+ coord_cartesian(ylim = c(0, ifelse(Main==TRUE, 580, max(YCI$X97.5.)))) + #annotate("text", x=Inf, y = Inf, label = paste("P(beta[1]<0)== ", round(Neg, 3)), parse=TRUE,vjust=2, hjust=1)+ annotate("text", x=Inf, y = Inf,label = "c)",vjust=1, hjust=1)+ theme(axis.ticks.length=unit(-0.10, "cm"), axis.text.y = element_text(margin=margin(0,4,0,0,"pt"),colour="grey20",face="plain"), axis.text.x = element_text(margin=margin(5,0,0,0,"pt"),colour="grey20",face="plain")) if(SavePlots){ggsave(CVlamblines, file= paste("CVlambBoot_lines",av[Res],".png", sep=""), width = 4, height =3, dpi= 300) } #### GT #### Xstandard<-matrix(seq(min(dfVar$GTlow), max(dfVar$GThigh),length.out = 50)) Y<-matrix(nrow=boot, ncol= 50) Ystandard<-matrix(nrow=boot, ncol= 50) X<-matrix(nrow=boot, ncol= 50) for(i in 1:boot){ Y[i,]<-Estim_GT[i,1]+ seq(LinesX_GT[i,1], LinesX_GT[i,2], length.out = 50) * Estim_GT[i,2] Ystandard[i,]<-Estim_GT[i,1]+ Xstandard * Estim_GT[i,2] X[i,]<-seq(LinesX_GT[i,1], LinesX_GT[i,2], length.out = 50) } YCI<-apply(Ystandard, 2, function(Ystandard) quantile(Ystandard, probs = c(0,0.025, 0.5, 0.975, 1), names = TRUE)) YCI<-data.frame(t(YCI)) YCI$X<-Xstandard Y<-data.frame(t(Y)) dfY<-melt(Y) X<-data.frame(t(X)) dfX<-melt(X) dfBoot<-cbind(dfY, dfX$value) colnames(dfBoot)<-c("BootN", "Scaling", "LH") dfVar$LongLine<-ifelse(dfVar$lhigh>ifelse(Main==TRUE, log(700), max(YCI$X97.5.)),"dashed", "solid") dfBoot$Scaling<-exp(dfBoot$Scaling) YCI[,1:5]<-exp(YCI[,1:5]) #### ...lines #### Pos<-prop.table(table(ifelse(Estim_GT[,2]>0, "Neg.", "Pos.")))[1] ModGT<-summary(glm(meanl ~ meanGT, data=dfVar, family= "gaussian")) GTlines<-ggplot(dfVar, aes(meanGT, exp(meanl)))+ geom_ribbon(data=YCI, aes(ymin = X2.5., ymax = X97.5., x= X),fill = "grey80", alpha=0.7,inherit.aes = FALSE) + geom_line(data=YCI, aes(y= X50., x = X), inherit.aes = FALSE)+ geom_errorbar(aes(x= meanGT, ymin =exp(llow), ymax = exp(lhigh), width=0),color="grey40", linetype=dfVar$LongLine)+ geom_errorbarh(aes(y= exp(meanl), xmin =GTlow, xmax = GThigh, height=0),alpha=0.5,color="grey40")+ geom_point(col= "black", alpha= 0.7)+ theme_classic()+ labs(x = expression(paste(italic("GT"), "(years)")), y = expression(italic(l)["r"](km)))+ coord_cartesian(ylim = c(0, ifelse(Main==TRUE, 680, max(YCI$X97.5.)))) + #annotate("text", x=8, y = Inf, label = paste("P(beta[1]>0)== ", round(Neg, 3)), parse=TRUE,vjust=1, hjust=1)+ annotate("text", x=Inf, y = Inf,label = "a)",vjust=1, hjust=1)+ theme(axis.ticks.length=unit(-0.10, "cm"), axis.text.y = element_text(margin=margin(0,4,0,0,"pt"),colour="grey20",face="plain"), axis.text.x = element_text(margin=margin(5,0,0,0,"pt"),colour="grey20",face="plain")) if(SavePlots){ggsave(GTlines, file= paste("GTBoot_lines",av[Res],".png", sep=""), width = 4, height =3, dpi= 300)} #print("GT plots done") print(paste(av[Res],"is done" )) LinePlotsR[[Res]] <- list(Mlines, VarMlines, lamblines, CVlamblines, GTlines) } setwd("\\\\home.ansatt.ntnu.no/jonatanf/Documents/PhD/Chapter1/Data/") save(LinePlotsR, file= "LinePlotsR.rda") setwd("\\\\home.ansatt.ntnu.no/jonatanf/Documents/PhD/Chapter1/Figures/NP.BOOT.Synch_LHist.Resolutions-r/LogResponse/") source("\\\\home.ansatt.ntnu.no/jonatanf/Documents/PhD/Chapter1/Scripts/FastSlowArrows.r") PlotsBYl<-arrangeGrob( grobs=list(LinePlotsR[[8]][[5]]+ theme(axis.text.y = element_text(angle = 90, hjust = 0.5), plot.margin = unit(c(0,0,0,0), "mm")), LinePlotsR[[8]][[3]]+ theme(axis.text.y = element_text(angle = 90, hjust = 0.5), plot.margin = unit(c(0,2,0,0), "mm")), LinePlotsR[[8]][[4]]+ theme(axis.title.y = element_blank(),axis.text.y = element_text(angle = 90, hjust = 0.5),plot.margin = unit(c(0,1,0,0), "mm")), LinePlotsR[[8]][[1]]+ theme(axis.text.y = element_text(angle = 90, hjust = 0.5), plot.margin = unit(c(0,2,0,0), "mm")), LinePlotsR[[8]][[2]]+ theme(axis.title.y = element_blank(),axis.text.y = element_text(angle = 90, hjust = 0.5),plot.margin = unit(c(0,1,0,0), "mm")), FSconti+theme(plot.margin = unit(c(0,0,0,0), "mm")),SFconti), widths = c(57,53), heights = c(43,6,3, 43,43,6), layout_matrix = rbind(c(1, NA), c(6,NA), c(NA, NA), c(2 , 3), c(4, 5), c(7,7))) ggsave(PlotsBYl, file="PlotsBYlR.pdf", width = 110 , height = 120, dpi = 600, units="mm") ggsave(PlotsBYl, file="PlotsBYlR.tiff", width = 110 , height = 120, dpi = 600, units="mm")