从预测图中删除灰色背景置信区间

我用点预测和置信区间创建了预测图.但是,我只想要没有置信区间(灰色背景)的点预测(蓝线).我怎么做?下面是我目前的代码和我的情节的截图.

  plot(snv.data$mean,main="Forecast for monthly Turnover in Food   
  Retailing",xlab="Years",ylab="$million",+ geom_smooth(se=FALSE))

https://i.stack.imgur.com/A5zqM.png

最佳答案 目前在我看来,你尝试在基本功能图和ggplot2函数geom_smooth之间混合.在这种情况下,我认为这不是一个好主意.

既然你想使用geom_smooth,为什么不试着用`ggplot2’来做呢?

以下是如何使用ggplot2(我使用R-included airmiles数据作为示例数据)

library(ggplot2)
data = data.frame("Years"=seq(1937,1960,1),"Miles"=airmiles) #Creating a sample dataset

ggplot(data,aes(x=Years,y=Miles))+ 
        geom_point()+ 
        geom_smooth(se=F) 

使用ggplot,您可以在ggplot()调用的aes()中一次性设置x和y变量等选项,这就是为什么我不需要对geom_point()调用任何aes()的原因.

然后我添加更平滑的函数geom_smooth(),选项se = F以删除置信区间

点赞