[Rd] Title obscured when using par(mfrow) (PR#3463)

Uwe Ligges ligges at statistik.uni-dortmund.de
Sat Jul 12 16:09:29 MEST 2003


brahm at alum.mit.edu wrote:

> I want to put multiple plots on a page using par(mfrow), then a single title at
> the top.  This should work, but doesn't:
> 
>  R> par(oma=c(0,0,4,0), mfrow=c(3,4))
>  R> for (i in 1:12) {plot(1); title(i)}
>  R> ## text(10,10, ".")
>  R> par(mfrow=c(1,1), oma=c(0,0,1,0))
>  R> title("Main Title")

It's a clipping issue. Setting par(mfrow) twice is not documented to 
work. I wouldn't call it a bug.
Use mtext() instead of title() as in:

  par(oma=c(0,0,4,0), mfrow=c(3,4))
  for (i in 1:12) {plot(1); title(i)}
  par(mfrow=c(1,1), oma=c(0,0,1,0))
  mtext("Main Title", 3, outer = TRUE, cex = par("cex.main"))

The same for the example given below.

Uwe Ligges

> The main title does not appear.  However, uncommenting the third line (making
> an otherwise superfluous call to "text") fixes the problem.
> 
> This seems to be true regardless of whether my device is x11, postscript, or
> pdf.  The diff of the Postscript files (without and with the "text" command)
> may be illuminating to some experts:
> 
>   mica> diff bug.ps nobug.ps 
>   1083a1084,1085
>   > 623.97 66.47 754.04 158.36 cl
>   > 18.00 18.00 774.00 579.60 cl
>   1084a1087
>   > 0 0 0 rgb
> 
> Finally, here's an interesting variation, in which only the left side of the
> title is obscured:
> 
>  R> par(mfrow=c(1,2))
>  R> for (i in 1:2) plot(1)
>  R> ## text(10,10, ".")
>  R> par(mfrow=c(1,1))
>  R> title("Main Title")
> 
> Again, uncommenting the third line allows the full title to appear.
> 
> 
> Version:
>  platform = sparc-sun-solaris2.8
>  arch = sparc
>  os = solaris2.8
>  system = sparc, solaris2.8
>  status = 
>  major = 1
>  minor = 7.1
>  year = 2003
>  month = 06
>  day = 16
>  language = R
> 
> Search Path:
>  .GlobalEnv, package:misc, package:io, package:arrays, package:ls1, package:obsi, package:g.data, package:db, package:ts, package:ctest, Autoloads, package:base



More information about the R-devel mailing list