I want to create vertical bands for a line chart using ggplot2 or any other way in R.
date <- seq.Date(from = as.Date("2015/01/01"), to = as.Date("2018/01/01"), by = 1)
data <- runif(1097)
df <- data.frame(cbind(date,data))
df$date <- as.Date(df$date)
datebreaks <- seq(as.Date("2015/01/01"), as.Date("2018/01/01"), by = "3 month")
ggplot(df, aes(x = date, y = data)) +
geom_line() + ylim(-1,2) +
scale_x_date(breaks = datebreaks)
What I need is a chart with alternate quarters shaded.