绘制回归线,abline [英] plot regression line, abline

查看:111
本文介绍了绘制回归线,abline的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个情节

plot(wine$AGST ~ wine$Price, xlab="Price", ylab = "AGST", pch = 19)

并想画一条回归线即

abline(lm(Price ~ AGST, data=wine))

但面临错误即

abline(mod01)警告信息:1:在 doTryCatch(return(expr), name, parentenv, handler) 中:lm"不是图形参数2:在 doTryCatch(return(expr), name, parentenv, handler) 中:lm"不是图形参数abline(lm(Price ~ AGST, data=wine))警告信息:1:在 doTryCatch(return(expr), name, parentenv, handler) 中:lm"不是图形参数2:在 doTryCatch(return(expr), name, parentenv, handler) 中:lm"不是图形参数abline(lm(Price ~ AGST, data=wine))警告信息:1:在 doTryCatch(return(expr), name, parentenv, handler) 中:lm"不是图形参数2:在 doTryCatch(return(expr), name, parentenv, handler) 中:lm"不是图形参数

abline(mod01) Warning messages: 1: In doTryCatch(return(expr), name, parentenv, handler) : "lm" is not a graphical parameter 2: In doTryCatch(return(expr), name, parentenv, handler) : "lm" is not a graphical parameter abline(lm(Price ~ AGST, data=wine)) Warning messages: 1: In doTryCatch(return(expr), name, parentenv, handler) : "lm" is not a graphical parameter 2: In doTryCatch(return(expr), name, parentenv, handler) : "lm" is not a graphical parameter abline(lm(Price ~ AGST, data=wine)) Warning messages: 1: In doTryCatch(return(expr), name, parentenv, handler) : "lm" is not a graphical parameter 2: In doTryCatch(return(expr), name, parentenv, handler) : "lm" is not a graphical parameter

推荐答案

请提供可重现的示例.这是来自 mtcars 数据的一个例子

Please provide reproducible example. Here is one example from mtcars data

请记住图 (A ~ B) 将 A 绘制为 Y 轴,将 B 绘制为 X 轴而 plot(A , B) 将 A 绘制为 X 轴,将 B 绘制为 Y 轴

Keep in mind that The plot (A ~ B) plots A as Y axis and B as X axis While plot(A , B) plots A as X axis and B as Y axis

用你的数据尝试下面的代码,让我知道结果

Try following code with your data and let me know the result

plot(mtcars$mpg , mtcars$wt, xlab="mpg", ylab = "wt", pch = 19)
abline(lm(wt ~ mpg, mtcars))

这篇关于绘制回归线,abline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆