David L Carlson <dcarlson <at> tamu.edu> writes: > > This is more complicated, but it could be rolled up into a function. Replace your mtext() call with the following: > > # Set character expansion size > cx <- 2.5 > # Get the plot coordinates and the character size > ur <- par("usr")[c(1, 4)] > chr <- par("cxy") > rect(ur[1]+chr[1]/10, ur[2]-chr[2]*cx, ur[1]+chr[1]*cx, ur[2]-chr[1]/10, > border=NA, col="white") > text(ur[1]+chr[1]*cx/2, ur[2]-chr[2]*cx/2, "a", font=2, cex=2.5, col="red") > > 1) Assign to cx the cex= value that you are using in text(). > 2) Then get the upper right corner of the plot window and the size of the default character width in user > coordinate units. > 3) Draw a white rectangle the size of the character you are plotting (in this case cex=2.5). Shrink the left > and top edge so that the box around the plot area is not obscured. > 4) Plot your character in the center of the box. >
There are two more tricks you can use here: (1) cheat by using legend() plot(0:10,0:10) legend("topleft",legend=NA,title="hello",bty="n") (2) use plotrix::corner.label ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.