library(ggplot2) # ggplot is a better plotting program, aes() stands for aesthetics and contains the # variables ggplot(d, aes(x = x, y = y)) + geom_smooth(method = "lm", se = FALSE, color = "red") + geom_segment(aes(xend = x, yend = predicted), alpha = .2) + # you can easily add elements, e.g. points geom_point() + geom_point(aes(y = predicted), shape = 1) + theme_bw()