[R] title problem

Peter Ehlers ehlers at ucalgary.ca
Sat Nov 21 23:51:53 CET 2009


David Winsemius wrote:
> 
> On Nov 21, 2009, at 1:19 PM, Gary wrote:
> 
>> I think Gabor suggestion works. Adding "line=" option in title makes 
>> it work. Here is a little modification of what Gabor suggested, Carol 
>> you may try this code:
>>
>> par(oma=c(3,1,4,1))
>> par(mfrow = c(1,2))
>> plot(c(1,2,3), c(9,8,7))
>> plot(c(1,2,3), c(9,8,7))
>> title(main = "Main title line1\nMain title line2", cex.main=1.5, 
>> line=1, sub = "Sub title line1\nSub title line2", cex.sub = 0.75, 
>> outer = TRUE)
> 
> Agree it works. Apparently setting line to something other than the 
> default = NA is necessary. To get it to work as I expected I needed to 
> set line=0. The help page was not particularly helpful in this regard. 
> Am I correct in thinking that title() adds 1 to NA and gets NA for the 
> subtitle placement, but that this is not happening for the title 
> placement? (Could not figure out what was really happening because could 
> not expose the code of as.graphicAnnot(). If so, shouldn't this be fixed?
> 
> oprar <- par(oma=c(1,1,2,1))
> par(mfrow = c(1,2))
> plot(c(1,2,3), c(9,8,7))
> plot(c(1,2,3), c(9,8,7))
> title(main = "Main title line1\nline2", line=0, sub = "Sub title 
> line1",  outer = TRUE)
> par(opar)
> 
> 
> So now the number of displayed lines equals the number of specified 
> lines in par()$oma
> 
At the risk of beating a dead horse, let me add this:
I always use two calls to title(), one for main and one
for sub. This gives me flexibility in setting different
values for the line argument. Or, of course, one can use
mtext() as suggested earlier by David.

  -Peter Ehlers




More information about the R-help mailing list