Library, colors

library(MASS)
library(grDevices)
tab_r<-c(0,255,162,137,171,89,95,207,255,200)
tab_g<-c(107,128,200,137,171,89,158,207,188,82)
tab_b<-c(164,14,236,137,171,89,209,207,121,0)
tab_color=vector();
for(i in 1:10){ tab_color[i]=rgb(tab_r[i],tab_g[i],tab_b[i],maxColorValue = 255) }

Make matrix of height,width,temp

hmat=mvrnorm(10000,c(200,.75,15),matrix(nrow=3,ncol=3,c(150,0.1,-30,
                                                       0.1,.05,.3,
                                                       -30,.3,15),byrow=T))
colnames(hmat)=c("height","width","temp")
#fix width ugly
hmat[which(hmat[,2]<0),2]=-1*hmat[which(hmat[,2]<0),2]

Check relationships among variables

#height, weight
plot(hmat[,1]~hmat[,2],pch=16,cex=0.5,col=tab_color[1],xlab="width",ylab="height"); abline(lm(hmat[,1]~hmat[,2]),col=tab_color[4],lwd=3)
legend("topleft",legend=paste(cor(hmat[,1],hmat[,2])),box.lwd=0)

plot of chunk unnamed-chunk-3

#height, temp
plot(hmat[,1]~hmat[,3],pch=16,cex=0.5,col=tab_color[2],xlab="temp",ylab="height"); abline(lm(hmat[,1]~hmat[,3]),col=tab_color[4],lwd=3)
legend("topleft",legend=paste(cor(hmat[,1],hmat[,3])),box.lwd=0)

plot of chunk unnamed-chunk-3

#width,temp
plot(hmat[,2]~hmat[,3],pch=16,cex=0.5,col=tab_color[3],xlab="temp",ylab="width"); abline(lm(hmat[,2]~hmat[,3]),col=tab_color[4],lwd=3)
legend("topleft",legend=paste(cor(hmat[,3],hmat[,2])),box.lwd=0)

plot of chunk unnamed-chunk-3

Make volume of plants, show it behaves right compared to width, height

vol=function(d,h){ pi*(h/3)*((d/2)^2) }
volume=sapply(1:10000,function(x) vol(hmat[x,2],hmat[x,1]) )
plot(volume~hmat[,2],cex=0.5,pch=16)

plot of chunk unnamed-chunk-4

plot(volume~hmat[,1],cex=0.5,pch=16)

plot of chunk unnamed-chunk-4

Compare volume to temp

plot(volume~hmat[,3],cex=0.5,pch=16,col=tab_color[5]); abline(lm(volume~hmat[,3]),col="red",lwd=3)
legend("topleft",legend=paste(cor(volume,hmat[,3])),box.lwd=0)

plot of chunk unnamed-chunk-5