pred<-predict(year_gam, type = "terms", se = TRUE) I<-order(nottem_year) plusCI<-I(pred$fit[,1] + 1.96*pred$se[,1]) minusCI<-I(pred$fit[,1] - 1.96*pred$se[,1]) xx <- c(nottem_year[I],rev(nottem_year[I])) yy <- c(plusCI[I],rev(minusCI[I])) plot(xx,yy,type="n",cex.axis=1.2) polygon(xx,yy,col="light grey",border="light grey") lines(nottem_year[I], pred$fit[,1][I],lty=1) abline(h=0)