################################################### ### Page 3 ################################################### par(omi=rep(1,4), fig=c(0, 0.5, 0, 1)) ################################################### ### Page 3 ################################################### par(fig=c(0.1, 0.6, 0.1, 0.6)) plot(c(0, 1), c(0, 1), type="n", xlab="", ylab="", axes=FALSE) box() text(.5, .5, "Figure 1") par(new=T) par(fig=c(0.4, 0.9, 0.4, 0.8)) plot(c(0, 1), c(0, 1), type="n", xlab="", ylab="", axes=FALSE) box() text(.5, .5, "Figure 2") ################################################### ### Page 5 ################################################### plot(x, y, xlim=c(0, 10), ylim=c(50, 100)) ################################################### ### Page 5 ################################################### plot(x, y, xlim=c(0, 10), ylim=c(50, 100), xaxs="i", yaxs="i") ################################################### ### Page 8 ################################################### midpts <- barplot(1:10, density=-1) text(midpts, 0.1, 1:10, srt=90, adj=0) ################################################### ### Page 10 ################################################### E.intervals <- co.intervals(ethanol$E, 16, 0.25) coplot(NOx ~ C | E, given.values = E.intervals, data = ethanol, panel = function(x, y, col, pch) { points(x, y, cex=1.5); axis(1, tck=1, lty=2, labels=F); axis(2, tck=1, lty=2, labels=F) }) ################################################### ### Page 10 ################################################### par(omi=rep(0, 4), mar=c(5.1, 4.1, 4.1, 2.1), mfrow=c(1, 1)) plot(0, type="n", xlim=c(0, 10), ylim=c(0,10), axes=F, xlab="", ylab="") par(col=1, lty=1, lwd=1, cex=1, srt=0) box() axis(1) axis(2) points(1:10) mtext("1:10", side=2, line=3) ################################################### ### Pages 10-12 ################################################### par(fig=c(0, 0.8, 0, 1), mar=c(4, 4, 4, 2)) barplot(matrix(sample(1:4, 16, replace=T), ncol=4), angle=45, density=1:4*10, col=1) par(new=T) par(fig=c(0.8, 1, 0, 1), mar=c(4, 0, 4, 2)) plot(0, xlim=c(0, 1), ylim=c(0, 5), axes=F, xlab="", ylab="", type="n") size <- par("cxy")/par("cin")*.5 box(lty=2) for (i in 1:4) { polygon(c(0.5 - size[1]/2, 0.5 - size[1]/2, 0.5 + size[1]/2, 0.5 + size[1]/2), c(i, i + size[2], i + size[2], i), angle=45, density=i*10) text(0.5, i-0.2, paste("Group", i)) } ################################################### ### Page 13 ################################################### x <- rnorm(100) y <- rnorm(100) g <- sample(1:8, 100, replace=T) ################################################### ### Page 13 ################################################### xyplot(y ~ x | g, layout=c(2, 4)) ################################################### ### Page 13 ################################################### xyplot(y ~ x | g, aspect=0.5) ################################################### ### Page 13 ################################################### myplot <- xyplot(y ~ x | g) print.trellis(myplot, position=c(0, 0.5, 1, 1)) ################################################### ### Page 13 ################################################### xyplot(y ~ x | g, scales=list(limits=c(-4, 4))) ################################################### ### Page 14 ################################################### xyplot(y ~ x | g, panel=function(x, y, ...) { panel.xyplot(x, y, ...); abline(0, 0) }) ################################################### ### Page 14 ################################################### xyplot(y ~ x | g, strip=function(which.given, which.panel, var.name, factor.levels, shingle.intervals, par.strip.text, strip.names, style) { text(0, 0.5, paste("Variable ", which.given, ": Level ", which.panel[which.given], sep=""), adj=0) }) ################################################### ### Page 14 ################################################### xyplot(y ~x|g, prepanel=function(x ,y) { list(xlim=range(x)+c(-1,1), ylim=range(y)+c(-1,1)) }) ################################################### ### Page 14 ################################################### xyplot(y~x|g,pch=16) ################################################### ### Pages 14-15 ################################################### trellis.par.get("plot.symbol") trellis.par.get("plot.line") ################################################### ### Page 15 ################################################### ps <- trellis.par.get("plot.symbol") ps$pch=16 trellis.par.set("plot.symbol", ps)