### von ~/R/r-release/R/demos/graphics/graphics.R : ps.latex("showoff-notchbox.ps",main = TRUE) par(bg="cornsilk") n <- 10 g <- gl(n, 100, n*100) x <- rnorm(n*100) + sqrt(codes(g)) boxplot(split(x,g), col="lavender", notch=TRUE) title(main="Notched Boxplots", xlab="Group", font.main=4, font.lab=1) ps.end() ## example(boxplot) ps.latex("showoff-insectsprays.ps") data(InsectSprays) boxplot(count ~ spray, data = InsectSprays, col = "lavender")# notch ist blöd ps.end() ### from example(polygon) n <- 100 xx <- c(0:n, n:0) ps.latex("showoff-brownian.ps", main = TRUE) par(bg="cornsilk") set.seed(152) mult.fig(4, main ="Distance Between Brownian Motions", marP = c(-1,-1,-2,0)) for(i in 1:4) { yy <- c(c(0,cumsum(rnorm(n))), rev(c(0,cumsum(rnorm(n))))) plot (xx, yy, type="n", xlab="Time", ylab="Distance") polygon(xx, yy, col="gray", border = "red") } ps.end() ##--------------------- data(state) attach(data.frame(state.x77))#> don't need `data' arg. below ps.latex("showoff-coplot-state.ps", main = TRUE) ## Doing a title in a coplot seems a major kludge !!! ##mtext("coplot(Life.Exp ~ Income | Illiteracy * state.region", ## side = 3, outer = TRUE, line = 2, cex = 1.5, col = "dark gray") coplot(Life.Exp ~ Income | Illiteracy * state.region, number = 3, panel = function(x, y, ...) panel.smooth(x, y, span = .8, ...)) ps.end() detach() # data.frame(state.x77) ###--- From ~/Vorl/Vis-StGallen/Discrete-Data.R : ps.latex("showoff-mosaic-UCB.ps", main = TRUE) data(UCBAdmissions) ##--- is there a Gender Bias? ## Type ?UCBAdmissions tit.UCB <- "UC Berkeley admissions (1973)" ## Use the Berkeley admission data as in Friendly (1995). UCB.A <- aperm(UCBAdmissions, c(2, 1, 3)) dimnames(UCB.A)[[2]] <- c("Yes", "No") names(dimnames(UCB.A)) <- c("Gender", "Admit?", "Department") mosaicplot(UCB.A, shade = TRUE,main = tit.UCB) ps.end() ###--- R base examples : ## example(airquality): ps.latex("showoff-pairs-air.ps", height=8, width=8) data(airquality) pairs(airquality, panel = panel.smooth, main = "airquality data", cex = .8) ps.end() ps.latex("showoff-pairs-hist.ps", height=8, width=8) data(USJudgeRatings) ## put histograms on the diagonal panel.hist <- function(x, ...) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(usr[1:2], 0, 1.5) ) h <- hist(x, plot = FALSE) breaks <- h$breaks; nB <- length(breaks) y <- h$counts; y <- y/max(y) rect(breaks[-nB], 0, breaks[-1], y, col="cyan", ...) } pairs(USJudgeRatings[1:5], panel=panel.smooth, cex = 1.5, pch = 24, bg="light blue", diag.panel=panel.hist, cex.labels = 2, font.labels=2) ps.end()