Приведенный ниже код может отображать график с несколькими строками с легендой графика.
df2 = data.frame(matrix(data=c(
30.89336, 32.33668, 41.63653, 69.82661, 108.06855,
30.98103, 32.24805, 41.33295, 69.44308, 104.36587,
30.73076, 32.11497, 40.76273, 69.59129, 97.30812,
30.76028, 30.50381, 36.56215, 62.50329, 61.78828,
29.76733, 34.65090, 43.94289, 93.20954, 113.42410
), ncol = 5, byrow = TRUE ))
colnames(df2) = c("NSW1.Price", "Black.Coal", "Gas", "Hydro", "Liquid.Fuel")
df1 = data.frame("time" = as.Date(
c("2011-01-01",
"2011-01-08",
"2011-01-15",
"2011-01-22",
"2011-01-29"),"%Y-%m-%d"))
df = cbind(df1, df2)
plot(0, cex=0, xlim=range(df$time),
ylim=c(0,max(c(df$NSW1.Price, df$Black.Coal))))
lines(df$time, df$NSW1.Price, col="cyan", lty = 1)
lines(df$time, df$Black.Coal, col="black", lty=2)
legend("bottomleft", legend = c("NSW1.Price", "Black.Coal"),
col = c("cyan", "black"), lty = c(1,2))