Mike Livermore – CSI 773 – Week 2 Assignment – Lecture Examples – September 2010
1:
2:
3.1:
3.2:
windows()
cex = .9
xAxisTick = -.03
xAxisTickSep = .3
yAxisTick = -.02 # These are for the y-axis
yAxisTickSep = .5
# panel layout
panels = panelLayout(nrow=2,ncol=1,rowSep=c(0,.2,0),leftMar=.42)
# plot two curves and difference
rx = c(-.04,1.04)
ry = c(-.04,1.04)
xgrid = seq(0,1,by=.2)
ygrid = c(0,.25,.5,.75,1)
panelSelect(panels,1,1)
panelScale(rx,ry)
panelFill()
panelGrid(x=xgrid,y=ygrid,col="white",lwd=2)
axis(side=2,at=ygrid,tck=yAxisTick,mgp=c(2,yAxisTickSep,0),las=2,cex=cex)
# mtext() could be used instead
# mtext(side=2,line=.3,text=format(ygrid),at=ygrid,las=2,cex=cex)
lines(x,y1,lwd=3)
lines(x,y2,lwd=3)
lines(x,curveDif,lwd=3,col="blue")
panelOutline()
mtext(side=3,line=2.4,'Top Panel: Two Curves and Their Difference',cex=1.3)
mtext(side=3,line=.7,'Bottom Panel: Zoomed View of the Difference',cex=1.3)
# Rescale and plot difference
ry = c(.02,.14)
ygrid=c(.02,.05,.08,.11,.14)
panelSelect(panels,2,1)
panelScale(rx,ry)
panelFill()
panelGrid(x=xgrid,y=ygrid,col="white",lwd=2)
axis(side=1,at=xgrid,mgp=c(2,xAxisTickSep,0),tck=xAxisTick,las=1,cex=cex)
axis(side=2,at=ygrid,mgp=c(2,yAxisTickSep,0),tck=yAxisTick,las=2,cex=cex)
lines(x,curveDif,lwd=3,col="blue")
panelOutline()
4: