how to get lines of different types to show in legend


plot(a, b,  type='l',  col='red')
lines(b, d, type='l', col='blue', lty='dashed')    
legend('topright', legend=c('x', 'y'), col=c('red','blue') lty=1) 

How do I get the legend to show the blue line in a dashed form.

Provide line types as a vector, like you did with the col argument. Can be vector of character names or the numbers that represent the line type used.

legend('topright', legend=c('x', 'y'), col=c('red','blue'), lty=c("solid", "dashed"))