On Wed, 28 Feb 2007 16:52:05 +0000 (GMT),
Jenny Barnes <[EMAIL PROTECTED]> wrote:

> Hi folks, Do you mind if I ask a related question that I have been
> having trouble with - how do you put the legend outside of the plot area
> (to the bottom of the area - below the x-axis title)? Could anybody show
> me using the example given below:

> x <- seq(-pi, pi, len = 65) plot(x, sin(x), type="l", col = 2) legend(x
> = -3, y = .9, "legend text", pch = 1, xjust = 0.5)

> Thank you, I've not been able to do this simple bit of programming and
> it is very frustrating not to be able to add a simple key.

Have a look at ?par and argument 'inset' in ?legend itself.  Here's one
way:


x <- seq(-pi, pi, len=65)
par(mar=c(par("mar")[1] + 2, par("mar")[-1]))
plot(x, sin(x), type="l", col=2)
par(xpd=TRUE)
legend("bottom", "legend text", pch=1, inset=-0.3)


-- 
Seb

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to