#load data & libaries library(smatr) # rm(list=ls()) # data4 <- read.csv('Trait data, 5-2-2014.csv', header = T, sep = ",") data4 <- read.csv('Trait data.csv', header = T, sep = ",") # _______________________ PLOTTING _____________________________________________### cool_dry <- subset (data4, climate.description == "Temperate_Dry", select = colnames(data4)) warm_wet <- subset (data4, climate.description == "Subtropical_Wet", select = colnames(data4)) hot_dry <- subset (data4, climate.description == "Tropical_Monsoonal", select = colnames(data4)) warm_arid <- subset (data4, climate.description == "Subtropical_Arid", select = colnames(data4)) warm_dry <- subset (data4, climate.description == "Subtropical_Dry", select = colnames(data4)) # ______________Fig 1 (leaf size ~ total_flow_petiole)__________________________________________## ## TURN ON IF SAVING TO FILE tiff(file="petiole_K vs LS2.tiff", height=4.1, width=4.5, units="in", res=200) # pdf("petiole_K vs LS.pdf", height=4.1, width=4.5) #postscript("myplot.eps", horizontal = FALSE, onefile = FALSE, paper = "special", height = 4.5, width = 5) par(mfrow=c(1,1), oma=c(0.2, 0.5, 0.2, 0.2), mai=c(0.7, 0.7, 0.3, 0.3), mgp=c(2, 0.5, 0)) # par(mfrow=c(1,1), oma=c(0.5, 0.5, 0.5, 0.5), mai=c(1, 0.9, 0.5, 0.5), mgp=c(2.2,0.5,0)) plot(data4[,"total_flow_pet..kg.m.s.Mpa."]*1000000, data4[,"leaf.size..cm2."],axes=FALSE, pch=19, cex.lab=1.2, cex=1.5, xlim=c(0.0003, 2), ylim=c(0.09, 100), log="xy", col="white", xlab=expression("petiole K (mg " * m^-1 *" "* s^-1*" "* MPa^-1 * ")"), ylab=expression("leaf size (" * cm^2 * ")")) labels <- c(0.001, 0.01, 0.1, 1) axis(1, tick=TRUE, line=0, tck=0.025, cex.axis=0.75, at=labels) axis(2, tick=TRUE, line=0, las=2, tck=0.025, cex.axis=0.75) box(bty="l") points(cool_dry[,"total_flow_pet..kg.m.s.Mpa."]*1000000, cool_dry[,"leaf.size..cm2."], pch=0, cex=1.2, col="blue",lwd=2) points(warm_wet[,"total_flow_pet..kg.m.s.Mpa."]*1000000, warm_wet[,"leaf.size..cm2."], pch=1, cex=1.2, col="darkorchid3",lwd=2) points(hot_dry[,"total_flow_pet..kg.m.s.Mpa."]*1000000, hot_dry[,"leaf.size..cm2."], pch=2, cex=1.2, col="red",lwd=2) points(warm_arid[,"total_flow_pet..kg.m.s.Mpa."]*1000000, warm_arid[,"leaf.size..cm2."], pch=3, cex=1.2, col="darkorchid3",lwd=2) points(warm_dry[,"total_flow_pet..kg.m.s.Mpa."]*1000000, warm_dry[,"leaf.size..cm2."], pch=5, cex=1.2, col="darkorchid3",lwd=2) OLS1=line.cis(log10(data4[,"leaf.size..cm2."]), log10(data4[,"total_flow_pet..kg.m.s.Mpa."]*1000000), method="SMA") curve(10^((log10(x)*(OLS1[2,1])+(OLS1[1,1]))), lwd=1, add=T, xlim=c(0.0003, 2)) # 1:1 direct proportionality line curve((x)*(500), lwd=1, lty=2, add=T, xlim=c(0.0003, 2), col="red") # title(main = expression("petiole ~ branch"), sub = NULL, xlab = NULL, ylab = NULL, # line = NA, outer = FALSE, cex.main=1.7) lm <- lm(log10(data4[,"total_flow_pet..kg.m.s.Mpa."]*1000000) ~ log10(data4[,"leaf.size..cm2."])); summary(lm) text <- expression(r^2 * " = 0.84, p < 0.001") legend("topleft", text, bty="n", cex=1) # ______________Fig 1, panel 2 (variance partitioning - Ks vs x-sec area bargraph)___________## par(fig = c(0.67, 0.89, 0.20, 0.48), new = TRUE) par(mgp=c(2.7,0.2,0)) par(mar = c(1.2, 0, 1.5, 0)) var_Ks <- c(46.6, 53.4) barplot(var_Ks, cex.axis=0.5, tck=FALSE) box(lty=1, bty="l") axis(2, tick=TRUE, line=0, labels=FALSE, tck=-0.05) axis(1, tick=FALSE, labels=FALSE, cex.axis=0.5) text(0.75, -7, cex=0.6, labels=expression(K[X]), xpd=TRUE) text(1.95, -7, cex=0.6, labels="xylem", xpd=TRUE) text(1.95, -16, cex=0.6, labels="area", xpd=TRUE) text(1.2, 69, cex=0.6, labels="explained", xpd=TRUE) text(1.2, 59, cex=0.6, labels="variance (%)", xpd=TRUE) # TURN ON/OFF dev.off()