I have time series with forecast and confidence interval data, I wanted to build them using ggplot2. I do this with the code below:
set.seed(321) library(ggplot2) #create some dummy data similar to mine sample<-rnorm(350) forecast<-rnorm(24) upper<-forecast+2*sd(forecast) lower<-forecast-2*sd(forecast) ## wrap data into a data.frame df1 = data.frame(time = seq(325,350,length=26), M = sample[325:350], isin = "observations") df2 = data.frame(time = seq(351,374,length=24), M = forecast , isin = "my_forecast") df3 = data.frame(time = seq(351,374,length=24), M = upper ,isin = "upper_bound") df4 = data.frame(time = seq(351,374,length=24), M = lower, isin = "lower_bound") df = rbind(df1, df2, df3, df4) ## ggplot object ggplot(df, aes(x = time, y = M, color = isin)) + geom_line()

How can I append the top and bottom lines of the same color? and also how can I set specific colors for prediction and sampling?
r plot ggplot2
Uzg
source share