plot( x = mtcars$wt, y = mtcars$mpg, main = "mpg vs wt", xlab = "wt (重量)", ylab = "mpg (每加仑英里数)", pch = 19, # 点的形状(19=实心圆) col = "steelblue")abline(lm(mtcars$mpg ~ mtcars$wt), col = "red", lwd = 2) # 线性回归拟合线
# install.packages("ggplot2")library(ggplot2)ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + geom_smooth(method = "lm", se = FALSE, color = "red") 
发表评论