Lets say I have some time series data that looks like this:
df <- data.frame(Month=seq(1,12),
Value = rnorm(12,0,1),
Season = c('Winter', 'Winter', 'Spring',
'Spring', 'Spring', 'Summer',
'Summer', 'Summer', 'Fall',
'Fall', 'Fall', 'Winter'))
I want to plot Value over time and show how it relates to Season. Plotting Value is easy, something like:
ggplot(data, aes(Month, Value)) + geom_line()
in ggplot or in base graphics:
plot(Value~Month, data=df, type='l')
What I'd like to do is compellingly overlay a factor. I would like to change the background color according to which month is on the x-axis. So, in my example, the left 1/6th would be, say white for winter, then the next third moving right would be yellow for spring, then the next third red for summer, etc, until rightmost 1/12th would be white again.
These seems like it should be something simple and easy for time series data, but I can't find any help on how to do this, in any graphics package. Any suggestions or insight would be appreciated!