Skip to content

title problem

12 messages · Gurmeet, Gary Miller, carol white +3 more

#
Hi,
I got problem in using title function to create a title for multiple plots presented together by par. As can be seen in the attached file, the title is displayed truncated and the subtitle doesn't get displayed. Here is the code:

  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", sub ="Sub title",outer = TRUE, cex.main=1.5, cex.sub = 1.5)

Carol


      
-------------- next part --------------
A non-text attachment was scrubbed...
Name: titlePb.png
Type: image/png
Size: 28006 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091121/a52046b6/attachment-0002.png>
#
On Nov 21, 2009, at 11:39 AM, Gary wrote:

            
I'm curious about what you are seeing with that sequence. On a Mac  
running R 2.10.0 I am not seeing the subtitle.
#
subtitle still doesn't get displayed
--- On Sat, 11/21/09, Gurmeet <gurmeet at email.unc.edu> wrote:

            
#
Thanks Gary. No I want one subtitle for all plots below the main title. subtitle should work but if doesn't at the worst case I could do as follows:

title(main = "Main title\nSub title",outer = TRUE, cex.main=1.5,...)
--- On Sat, 11/21/09, Gary <mail2garymiller at gmail.com> wrote:

            
#
Try the line= argument on title()

opar <- par(oma = 4 * c(1, 1, 1, 1), no.readonly = TRUE)
par(mfrow = 1:2)
plot(1:3, 9:7)
plot(1:3, 7:9)
for(i in 1:3) title(main = i, line = i, outer = TRUE)
par(opar)
On Sat, Nov 21, 2009 at 12:47 PM, carol white <wht_crl at yahoo.com> wrote:
#
On Nov 21, 2009, at 12:57 PM, Gabor Grothendieck wrote:

            
I was not sure what Carol was hoping for. I assumed she was hoping for  
the full page analog of what subtitle would do with an individual  
plot, i.e. that the subtitle would be below the plots and centered. If  
she were hoping for just another line below the main title, then your  
strategy or using "\n" within the string would be effective.

I think that she may need to use mtext() in order to get a "true" sub- 
title of the first sort.
#
On Nov 21, 2009, at 1:19 PM, Gary wrote:

            
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
#
David Winsemius wrote:
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