How can I create a proper legend with the corresponding line type and color? Also, how can I create a Title for this graph?
In my legend, R corresponds to the solid black line, L is the dashed red line, and G is the green dotted line
Here is the code on how I created my graph and my legend:
matplot(x_values, cbind(r_y_values, l_y_values, g_y_values), type = 'l', xlab='N', ylab='Time(ms)')
legend("topleft", legend=c("R", "L", "G"), col=c(1:3), inset=0.01)

Just specify an lty value.
legend("topleft", legend=c("R", "L", "G"), col=c(1:3), lty=1:3, inset=0.01)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With