[R] Change the text size of the title in a legend of a R plot.
Victor Gabillon
victor.gabillon at inria.fr
Fri Apr 29 13:56:32 CEST 2011
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
More information about the R-help
mailing list