Skip to content

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

2 messages · Steven McKinney, Remko Duursma

#
I haven't found any cex argument that works for just the legend title, but you
can get some modification of the title with the expression argument:

legend("topleft", legend=legtext,col=col,text.col=col,lwd=lwd, lty=lty,cex=1.1,ncol=3,
title = expression(bold("Horizons")),title.col="black")

Does that help?

Otherwise, you can of course figure out which functions do the legend plotting,
copy and modify those to get a title cex in place.

Steve McKinney
#
Hi Victor,

looking at the code for legend, it looks like the same 'cex' value is
used for the text in the legend as the title.

Here is a trick though: draw the legend twice, with different cex
values, and omitting title or text:


plot(1)
legend("topright",c("a","b"),title=" ")
legend("topright",c(" "," "),title="Legend",cex=0.6, bty='n', title.adj=0.15)


A bit of a hack but it works....
If you want the title larger, it will probably not fit the box, which
you can omit by setting bty='n' (as in the second line).

good luck,

Remko



-------------------------------------------------
Remko Duursma
Research Lecturer

Centre for Plants and the Environment
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Mobile: +61 (0)422 096908
www.remkoduursma.com
On Fri, Apr 29, 2011 at 3:15 PM, Steven McKinney <smckinney at bccrc.ca> wrote: