如何在图形中拟合模型线

时间:2017-07-05 15:36:36

标签: r

我尝试通过图形创建一条拟合线,但它根本没有显示,它只显示图形本身。我在这做错了什么?检查下面的代码。

cor.merged <- cor.merged[order(cor.merged$No.florets), ]
plot(vis.rate ~ No.florets, data = cor.merged[cor.merged$line == 'M',],
     main = "Nectar production vs visitation rate",
     xlab = "No.florets", ylab = "Visitation rate",
     pch = 19)
m1 <- lm(cor.merged$vis.rate[cor.merged$line == 'M'] ~ 
           poly(cor.merged$No.florets[cor.merged$line == 'M'], 2, raw = T))
summary(m1)
lines(cor.merged$No.florets[cor.merged$line == 'M'] ~  
      predict(m1), 
       col = 'red', lwd = 3, type = 'c')

0 个答案:

没有答案