Skip to content
Prev 23333 / 398500 Next

one question about title

Ken Lee <ken_lee at tynesys.com> asked (I'm paraphrasing) how to set cex.main
automatically so that his title will fit on the page.

Here's a solution that uses strwidth():

title.fit <- function(main, frac=.9, cex=par("cex.main"), ...) {
  while ((r <- strwidth(main, "f", cex)/frac) > 1.05) cex <- cex / r
  title(main, cex.main=cex, ...)
}