[R] Change the text size of the title in a legend of a R plot.

Jannis bt_jannis at yahoo.de
Fri Apr 29 10:03:07 CEST 2011

On 04/29/2011 05:21 AM, Victor Gabillon wrote:
> Horizo <- c(1,2,6,10,20)
> legtext <- paste(Horizo,sep="")
> legend("topleft", legend=legtext,col=col,text.col=col,lwd=lwd,
> lty=lty,cex=1.1,ncol=3,title = "Horizons",title.col 
> ="black",title.cex=1.4) 

I am not sure, but the manual regarding legend seems to be not correct 
(or at least misleading). There is not title.cex argument for legend 
(even though the help page mentions it). Either you set cex >1 but this 
will resize the labels as well. Or you modify the code of legend as follows:

change the following (near the end of the code):

            text2(left + w/2, top - ymax, labels = title, adj = c(0.5,
                 0), cex = cex, col = title.col)


            text2(left + w/2, top - ymax, labels = title, adj = c(0.5,
                 0), cex = title.cex, col = title.col)

and add title.cex to the arguments of legend. Its probably easiest if 
you copy the code of legend and save its modified version within a 
different function.

Not sure on whom to contact regarding correcting the documentation of 
legend(). Perhaps even I am wrong, but I could not find any reference to 
title.cex in the code.


More information about the R-help mailing list