[R] Producing a legend successfullly

Steve Murray smurray444 at hotmail.com
Mon May 4 20:46:02 CEST 2009

Dear all,

I'm attempting to insert a legend into a line graph. I've sorted out the positioning, but I'm unable to display the sample line and associated colour to go within the legend box. Instead, under the variable names, the numbers 1, 2, 2, 3 are displayed in a column (with '2' repeated twice). This is the code I'm using:

legend(80,1150, c("Simulation", "Observation", lty=1:2, col=2:3)

How do I go about displaying a red solid line next to 'Simulation' and a green dashed line next to 'Observation' (and if necessary, remove the numbers that are currently displayed)?

Many thanks for any help offered,


More information about the R-help mailing list