I'm trying to shade the background of the plot between points along the x-axis. These points are defined by a variable (x). Here's some data:
mydata <- data.frame(year = (2000:2010),
x = c(0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1),
y = (0:10))
So I want to have year as the x-axis and have a line connecting y points. I then want the background to be shaded if x=1, and to be normal otherwise. Any thoughts?
EDIT: Bonus points if you can stop if from connecting the two points when x changes.