Plot showing relationships between mean, absolute niche width, phylogenetic distance and co-occurrence
#dev.new(width=6.8, height=6.8)
layout(matrix(1:4,ncol=2), width = c(1,1),height = c(1,1))
par(mfrow=c(2,3))
par(mar=c(3.5,3,2.75,0.75), mgp=c(1.5,0.3,0), las=0)
plot(data.cooc$gen.spec,data.cooc$cooc.z, ylab="Co-occurrence", xlab="Difference in niche width",lwd=2, pch=16, col="black", cex.axis=1.25, cex.lab=1.5,bty="n", cex=1,tck=0.03)
#abline(cooc.z.gen.spec.lm, lwd=2)
box( lwd=3)
plot(data.cooc.mean$gen.spec,data.cooc.mean$cooc.z, ylab="Co-occurrence", xlab="Mean niche width",lwd=2, pch=16, col="black", cex.axis=1.25, cex.lab=1.5,bty="n", cex=1,tck=0.03)
#abline(cooc.z.gen.spec.lm, lwd=2)
box( lwd=3)
plot(sqrt(data.cooc$phy.dist),data.cooc$cooc.z, ylab="Co-occurrence", xlab="Phylogenetic distance (sqrt)",lwd=2, pch=16, col="black", cex.axis=1.25, cex.lab=1.5,bty="n", cex=1,tck=0.03)
#abline(cooc.z.phy.dist.lm, lwd=2)
box( lwd=3)
plot((data.cooc.30$gen.spec),data.cooc.30$cooc.z, ylab="Co-occurrence",xlab="Difference in niche width", lwd=2, pch=16, col="black", cex.axis=1.25, cex.lab=1.5,bty="n", cex=1,tck=0.03)
#abline(cooc.z.gen.spec.lm.30, lwd=2)
box(lwd=3)
plot((data.cooc.mean.30$gen.spec),data.cooc.mean.30$cooc.z, ylab="Co-occurrence",xlab="Mean niche width", lwd=2, pch=16, col="black", cex.axis=1.25, cex.lab=1.5,bty="n", cex=1,tck=0.03)
#abline(cooc.z.gen.spec.lm.30, lwd=2)
box(lwd=3)
plot(sqrt(data.cooc.30$phy.dist),data.cooc.30$cooc.z, ylab="Co-occurrence", xlab="Phylogenetic distance (sqrt)",lwd=2, pch=16, col="black", cex.axis=1.25, cex.lab=1.5,bty="n", cex=1,tck=0.03)
box(lwd=3)

#abline(cooc.z.phy.dist.lm.30, lwd=2)
#textClick("(a)",cex=c(size=1.5, font=2) )
#textClick("(b)", cex=c(size=1.5, font=2))
#textClick("(c)", cex=c(size=1.5, font=2))
#textClick("(d)", cex=c(size=1.5, font=2))
#textClick("(e)", cex=c(size=1.5, font=2))
#textClick("(f)", cex=c(size=1.5, font=2))
# Set up matrices for Mantel/partial Mantel
#mean.final.h.inv
#phy.dist.cyp #ordered by species names (including names), matrix form
#Create a matrix for cooc
z.mat<-(veg.out-meanmat)/sdmat
diag(z.mat)<-0