I am using a lattice package and I want to add a legend to my figure. The auto.key documentation and legend are very confusing and cannot determine the correct syntax for adding a legend. Here is my code:
xyplot(y ~ x, df, pch=19, col=rgb(0.2, 0.4, 0.8, 0.7), cex=2, scales=list(cex=1.7), xlab=list("x", cex=1.ales=list(cex=1.7), xlab=list("x", cex=1.7), ylab=list("y", cex=1.7), main=list("Linear Regression w. Polynomial Attributes", cex=1.6), auto.key=T, panel = function(x, y, ...) { panel.xyplot(x, y, ...) llines(x, predict(lm.xtend), col="purple", lwd=6, lty=3) llines(x, predict(ridge.lin), col="darkgreen", lwd=6, lty=2) })
The graph is shown below, so I just want to add a legend for the rows. 
source share