2015-03-31 41 views
2

以下代码显示abline的奇怪行为:绘制的线条未达到指定的拦截。我正在使用Rstudio版本0.98.976。任何提示以避免这个问题?abline不尊重R中的拦截

x=seq(1,10) 
y=seq(1,10) 
m=lm(y~x) 
summary(m) 
plot(x,y) 
abline(1.123e-15, 1.000e+00) 
abline(2, 1.000e+00) 
abline(3, 1.000e+00) 
abline(4, 1.000e+00) 

由于提前,

enter image description here

+0

所述的y值我什么都看不到zarre。你可以发布突出显示问题的图片吗? – Molx 2015-03-31 14:23:53

+1

设置轴风格:'plot(x,y,xaxs ='i',xlim = c(0,10))'然后看它 – rawr 2015-03-31 14:27:11

回答

3

这仅仅是一个透视的事项,由于截距是简单而x=0

x=seq(1,10) 
y=seq(1,10) 
m=lm(y~x) 
summary(m) 
plot(x,y, ylim = c(0,10), xlim= c(0,10)) 
abline(1.123e-15, 1) 
abline(2, 1.00) 
abline(3, 1.00) 
abline(4, 1.00) 
abline(v=0) 

enter image description here

+0

考虑张贴结果的图像。 – Thomas 2015-03-31 14:23:07

+0

认为人们会喜欢他们可以看到的可重现的例子,现在增加一个数字。 – 2015-03-31 14:24:16

+0

我已经加载图像,但我看不到它,也许我的电脑缺少一些东西... – 2015-03-31 14:28:57