library(ggplot2) library(cowplot) setwd("C:\\Users\\Madeleine\\Dropbox (CCIRA)\\Ecological Research - CCIRA\\Analyses\\Groundfish\\RCA-Pairing analyses\\Output\\20200330_DiveLength") predictions=read.csv("predictionTableTiger1.csv") summary(predictions$RCA_Name) predictions$ymin = predictions$predictions-1.96*predictions$SE predictions$ymax = predictions$predictions+1.96*predictions$SE #Change RCA names predictions$RCA_Name=as.character(predictions$RCA_Name) predictions$RCA_Name[which(predictions$RCA_Name=="Fish Egg Inlet")] = "Fish Egg Inlet" predictions$RCA_Name[which(predictions$RCA_Name=="West Aristazabal Island")] = "West Aristazabal" predictions$RCA_Name=as.factor(predictions$RCA_Name) #change factor names - RCA predictions$InRCA=as.character(predictions$InRCA) predictions$InRCA[which(predictions$InRCA=="in")]="Protected" predictions$InRCA[which(predictions$InRCA=="out")]="Control " predictions$InRCA=as.factor(predictions$InRCA) #change factor names - behaviour predictions$behaviour = as.character(predictions$behaviour) predictions$behaviour[which(predictions$behaviour=="Demersal-Low RM")]="Low mobility - Demersal" predictions$behaviour[which(predictions$behaviour=="Pelagic-High RM")]="High mobility - Benthopelagic " predictions$behaviour=as.factor(predictions$behaviour) #### plots #### setwd("C:\\Users\\Madeleine\\Dropbox (CCIRA)\\Ecological Research - CCIRA\\Analyses\\Groundfish\\RCA-Pairing analyses\\Output\\20200330_DiveLength\\plots") #frequency distribution # ggplot(data, aes(x=Complexity, color=RCA_Name,fill=RCA_Name))+geom_freqpoly(bins=4,size=2)+theme_classic() #only plot predictions forFishEgg, KB, West aristazabal predictions=predictions[which(predictions$RCA_Name%in%c("Fish Egg Inlet","McMullin Group","Kitasu Bay","West Aristazabal","Smith Sound","Goose Island")),] # plots of predictions #### predictionsK = predictions[which(predictions$Complexity==3&predictions$Depth==30&predictions$behaviour=="Low mobility - Demersal"&predictions$kAvg<0.16),] predictionsK$RCA_Name = factor(predictionsK$RCA_Name, levels = c("Goose Island","West Aristazabal","Kitasu Bay","Fish Egg Inlet","McMullin Group","Smith Sound")) A = ggplot(predictionsK,aes(x=kAvg, y=predictions, color=InRCA, fill=InRCA, ymin = ymin, ymax = ymax))+ geom_line(size=2) + geom_ribbon(alpha=0.2,color=NA) + facet_grid(cols=vars(RCA_Name))+theme_bw() x_axisTitle = expression(paste("Growth parameter ", italic("k"))) jpeg("20200410_TLbykAvg_Complex3_depth30v2_Tiger1.jpeg", width = 14, height = 5.5, units = 'in', quality=75, res=600) A + labs(y="Length anomaly",x=x_axisTitle)+theme(legend.title = element_blank(),text = element_text(size=21))+ scale_y_continuous(breaks=seq(-1.2,1.2,0.3))+theme(legend.position="top")+ theme(axis.text.x = element_text(size=16,angle = 45,hjust=1))+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) dev.off() predictionsC = predictions[which(predictions$Depth==15&predictions$kAvg==0.12& predictions$RCA_Name=="West Aristazabal"&predictions$InRCA=="Protected"),] A1 = ggplot(predictionsC,aes(x=Complexity, y=predictions, color=behaviour, fill=behaviour, ymin = ymin, ymax = ymax))+ geom_line(size=2) + geom_ribbon(alpha=0.15,color=NA) + theme_bw() A1 = A1 + labs(y="Length anomaly",x="Topographic Structural Complexity")+theme(legend.title = element_blank(),text = element_text(size=21))+ scale_y_continuous(limits=c(-0.9, 0.6),breaks = c(-0.9,-0.6,-0.3,0,0.3,0.6))+theme(legend.position="none")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) predictionsD = predictions[which(predictions$Complexity==2&predictions$kAvg==0.12& predictions$RCA_Name=="West Aristazabal"&predictions$InRCA=="Protected"),] A2 = ggplot(predictionsD,aes(x=Depth, y=predictions, color=behaviour, fill=behaviour, ymin = ymin, ymax = ymax))+ geom_line(size=2) + geom_ribbon(alpha=0.15,color=NA) + theme_bw() A2 = A2 + labs(y=" ",x="Depth (m)")+theme(legend.title = element_blank(),text = element_text(size=21))+ scale_y_continuous(limits=c(-0.9, 0.6),breaks = c(-0.9,-0.6,-0.3,0,0.3,0.6))+theme(legend.position="none")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) legend = get_legend(A1+theme(legend.position="top")) temp = plot_grid(A1,A2) jpeg("20200410_TLbyComplex2AndDepth15WAProtectedv2_Tiger1.jpeg", width = 14, height = 5.5, units = 'in', quality=75, res=600) plot_grid(legend,temp,ncol = 1, rel_heights = c(.1, 1)) dev.off()