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

From: Jannis <>
Date: Fri, 29 Apr 2011 10:03:07 +0200

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.

Jannis mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 29 Apr 2011 - 08:06:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Apr 2011 - 13:40:34 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive