用 plot() 绘制的两条线之间的填充区域

Fill area between two lines drawn with plot()

如何填充用 plot() 绘制的两条线之间的整个区域

plot(years,investments1)
plot(years,investments2)

感谢您的帮助。

ggplot 怎么样 geom_ribbon?

library(ggplot2)

set.seed(1)
df <- data.frame(
  x = seq(1,100),
  ymin = rnorm(100,10,3),
  ymax = rnorm(100,22,2) 
)

ggplot(df,aes(x=x))+
  geom_line(aes(x,ymin),color="red")+
  geom_ribbon(aes(ymin=ymin,ymax=ymax),fill="lightblue")+
  geom_line(aes(x=x,y=ymax),color="black")