I have a dataframe called blueshade in R, and I would like to shade certain background regions a time series interactive plot of this dataframe. I am trying to use plotly and ggplot Below is the code I have written so far.
months<-c("2007-05-01","2008-01-01","2009-01-01", "2010-01-01", "2011-01-01")
numbers<-c(1,8,50,11,3)
blueshade<-data.frame(months, numbers)
blueshade$months<-as.Date(blueshade$months)
p<-
ggplot(blueshade)+
geom_line(mapping=aes(x=months, y=numbers))
ggplotly(p)
If I would like to shade the region between 2007-05-01 and 2008-01-01 RED, and shade the region between 2009-01-01 and 2011-01-01 BLUE, does anyone know how I would write such code in R? I also want the shading to be somewhat transparent.