[R] Adding legends to a plot

liujb liujulia7 at yahoo.com
Tue Sep 30 21:03:08 CEST 2008


I have a time series plot drawn using 3 different colored lines, each line
corresponds to different category group. I'd like to put legends on the
plot. I am using "legend" to do this, however, I can either specify lty or
col in legend. Will I be able to do the following in the legend box: a solid
black line then g1, a solid red line then g2, a solid blue line then g3?

plot(g1, ylim=c(0,10))
lines(g2, col="red")
lines(g3, col="blue")
legend(locator(n=1), legend=c("g1", "g2", "g3"), ???)

Thank you very much,

View this message in context: http://www.nabble.com/Adding-legends-to-a-plot-tp19748373p19748373.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list