R/Adding letters
From QERM Wiki
Adding letters to identify sub-figures
Various journals want little letters in the corner. Here's some code to do it:
makeletter <- function(letter='a',position='topleft',xfrac=0.05,yfrac=0.05,...){ # puts a letter into the corner of a panel to match CJFAS requirements # very similar to something Trevor Branch (and who knows how many others) # created independently if(letter%in%1:9) letter <- letters[letter] p <- par('usr') if(position=='topleft') x <- p[1] + xfrac*diff(p[1:2]) if(position=='topright') x <- p[2] - xfrac*diff(p[1:2]) y <- p[4] - yfrac*diff(p[3:4]) text(x=x,y=y,paste('(',letter,')',sep=''),...) }
Apply using something like:
par(mfrow=c(2,2)) for(i in 1:4){plot(0); makeletter(i)}