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

From: Victor Gabillon <victor.gabillon_at_inria.fr>
Date: Fri, 29 Apr 2011 13:56:32 +0200

thanks everyone for the help.

I ended up copying and pasting the legend function from the R source files. I changed it so that the title.cex is not set by default to cex and so that this title.cex can be given as a parameter.

It works fine for me.
Note that if you make the title too big it goes out of the border as the borders were not designed for the case of a big title.

Thanks again!!

Victor

Le 29/04/2011 10:03, Jannis a écrit :
> 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)
>
> to:
>
> 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.
>
> HTH
> Jannis



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 29 Apr 2011 - 13:35:23 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:50:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive