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"))

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.