# chapter 3 of Braun and Murdoch (Graphics) rm(list=ls()) graphics.off() VADeaths class(VADeaths) # # mosaicplot(VADeaths, barplot(VADeaths, beside=TRUE, ylim=c(0, 90), # comment to stack legend=TRUE, ylab="Deaths per 1000", main="Death rates in Virginia") dotchart(VADeaths, xlim=c(0, 75), xlab="Deaths per 1000", main="Death rates in Virginia") groupsizes <- c(18, 30, 32, 10, 10) labels <- c("A", "B", "C", "D", "F") pie(groupsizes, labels, col=c("grey40", "white", "grey", "black", "grey90")) par(mfrow=c(1,1)) head(iris) boxplot(Sepal.Length ~ Species, data = iris, ylab = "Sepal length (cm)", main = "Iris measurements") #lower whisker to lower end of box is smallest value no smaller than #1.5 IQR below the lower quartile. Similarly, for upper whisker. Rationale for #these defs is that when data are from a ~normal distribution #~99% of the observations will fall between the whiskers. points(Sepal.Length ~ jitter(as.integer(Species)), data = iris,col="red") plot(1:24,pch=1:24) # normally send numbers to pch # but if pch is given a vec of strings, it uses the first char plot(1:26,pch=as.character(1:26)) # e.g. plot(1:26,pch=letters) # e.g. par() ?par par(mar=c(5, 5, 5, 5) + 0.1) plot(c(1, 9), c(0, 50), type='n', xlab="", ylab="") text(6, 40, "Plot region") points(6, 20) text(6, 20, "(6, 20)", adj=c(0, 0)) points(3, 30) text(3, 30, " some text", adj=c(0, 0),srt=0) text(3, 30, " some text", adj=c(0, 0),srt=90) text(3, 30, " some text", adj=c(0, 0),srt=180) text(3, 30, " some text", adj=c(0, 0),srt=270) mtext(paste("Margin", 1:4), side=1:4, line=3) mtext(paste("Line", 0:4), side=1, line=0:4, at=3, cex=0.6)