[R] legend question

Emili Tortosa-Ausina Emili.Tortosa at eco.uji.es
Wed Feb 28 17:06:18 CET 2007


Hi to all,

I'm sorry for posting this question, I am sure I am missing something 
important but after reading the documentation I cannot find where the 
problem is.

I want to add a legend to a figure. If I use a simple example drawn 
from the R Reference Manual such as, for instance:

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)

then everything works just fine.

However, if I use other data such as, for instance:

y<-c(1960, 1965, 1970, 1975)
z<-c(1, 2, 3, 4)
plot(y, z, type="l", col = 2)
legend(x = -3, y = .9, "legend text", pch = 1, xjust = 0.5)

then the legend is not shown.

Any hints?

Thanks in advance,

Emili



More information about the R-help mailing list