f.plot=function(x,y,nr=20,nc=20, scale="raw",...) { zx = c(1:nr,rep(1,nc),1+trunc( nr*(x- min(x))/(max(x)-min(x)) )) zx[zx>nr] = nr zy = c(rep(1,nr),1:nc,1+trunc( nc*(y- min(y))/(max(y)-min(y)) )) zy[zy>nc] = nc z = table(zx,zy); z[,1]=z[,1]-1; z[1,]=z[1,]-1; if (scale=="l") z= log(1+z) #image(z=t(z),x=seq(length=nr+1,from=min(x),to=max(x)), #y= seq(length=nc+1,from=min(y),to=max(y)), #xlab="",ylab="", col=rainbow(1000),...) contour(t(z),x=seq(length=nr,from=min(x),to=max(x)), y= seq(length=nc,from=min(y),to=max(y)),...) } x = rnorm(10000) ; y = rnorm(10000) ux = rnorm(5000)/3 uy = ux^2 -0.5 plot(c(y,uy)+20,c(x,ux),xlab="x",ylab="y",xlim=c(18,22),ylim=c(-2,2),pch=16) f.plot(c(y,uy)+20,c(x,ux),50,50,'l',xlim=c(18,23),ylim=c(-3.2,2.6)) f.plot(c(y,uy)+20,c(x,ux),50,50,'l',xlim=c(18,22),ylim=c(-3.2,2.6),nlevels=4) plot(c(y,uy)+20,c(x,ux),xlab="x",ylab="y",xlim=c(18,22),ylim=c(-2,2),pch=16) save.image("C:\\Documents and Settings\\EmirB\\Desktop\\LDesktop\\Columbia\\Computational Statistics Course\\Lecture\\.RData") f.plot(c(y,uy)+20,c(x,ux),50,50,'l',xlim=c(18,22),ylim=c(-3.2,2.6),nlevels=4) library(Rcmdr) ls() names(eff2) plot(eff2$PAIN0,eff2$PNCHG) plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base') plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots") plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots \n My test") plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots \n My test",xlim=c(4,10)) abline(h=0,lty=2,col=3,lwd=2) abline(h=0,lty=2,col="lightgrey",lwd=2) abline(h=0,lty=2,col="lightblue",lwd=2) ?abline abline(a=1,b=2,lty=1,col="red") abline(a=1,b=1,lty=1,col="red") lines(c(4,10),c(-10,4)) pdf("mygraph.pdf") plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots \n My test",xlim=c(4,10)) lines(c(4,10),c(-10,4)) abline(a=1,b=1,lty=1,col="red") dev.off() plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots \n My test",xlim=c(4,10)) dev.off() plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots \n My test",xlim=c(4,10)) plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots \n My test",xlim=c(4,10),pch=9)) plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots \n My test",xlim=c(4,10),pch=9) plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots \n My test",xlim=c(4,10),pch=8) plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',main="Scatterplots \n My test",xlim=c(4,10),pch=".") plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain",ylab='Change from base',col.lab=2,main="Scatterplots \n My test",xlim=c(4,10),pch=".") plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain", ylab='Change from base',col.lab=2,main="Scatterplots \n My test", xlim=c(4,10),pch=".",font=4,fon.lab=2) plot(eff2$PAIN0,eff2$PNCHG,xlab="Baseline Pain", ylab='Change from base',col.lab=2,main="Scatterplots \n My test", xlim=c(4,10),pch=".",font=4,font.lab=2) # specify the data x <- c(1:10); y <- x; z <- 10/x# create extra margin room on the right for an axis par(mar=c(5, 4, 4, 8) + 0.1)# plot x vs. y plot(x, y,type="b", pch=21, col="red",    yaxt="n", lty=3, xlab="", ylab="")# add x vs. 1/x lines(x, z, type="b", pch=22, col="blue", lty=2)# draw an axis on the left axis(2, at=x,labels=x, col.axis="red", las=2)# draw an axis on the right, with smaller text and ticks axis(4, at=z,labels=round(z,digits=2),  col.axis="blue", las=2, cex.axis=0.7, tck=-.01)# add a title for the right axis mtext("y=1/x", side=4, line=3, cex.lab=1,las=2, col="blue")# add a main title and bottom and left axis labels title("An Example of Creative Axes", xlab="X values",   ylab="Y=X") y x <- c(1:10); y <- x; z <- 10/x x y z par(mar=c(5, 4, 4, 8) + 0.1) plot(x, y,type="b", pch=21, col="red", yaxt="n", lty=3, xlab="", ylab="") lines(x, z, type="b", pch=22, col="blue", lty=2) axis(2, at=x,labels=x, col.axis="red", las=2) ?AXIS ?axis attach(mtcars)par(mfrow=c(2,2))plot(wt,mpg, main="Scatterplot of wt vs. mpg")plot(wt,disp, main="Scatterplot of wt vs disp")hist(wt, main="Histogram of wt")boxplot(wt, main="Boxplot of wt") par(mfrow=c(2,2)) plot(wt,mpg, main="Scatterplot of wt vs. mpg") plot(wt,disp, main="Scatterplot of wt vs disp") hist(wt, main="Histogram of wt") boxplot(wt, main="Boxplot of wt") attach(mtcars) detach() data(mtcars) ls() summary(mtcars) mtcasr mtcars attach(mtcars) par(mfrow=c(2,2)) plot(wt,mpg, main="Scatterplot of wt vs. mpg") plot(wt,disp, main="Scatterplot of wt vs disp") hist(wt, main="Histogram of wt") boxplot(wt, main="Boxplot of wt") par(mfrow=c(3,1)) hist(wt)hist(mpg)hist(disp) hist(wt) hist(mpg) hist(disp) par(mfrow=c(3,1)) hist(wt) hist(mpg) hist(disp) layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE), widths=c(3,1), heights=c(1,2)) hist(wt) hist(mpg) hist(disp)