In R, suppose I have a logical vector of the same length as the data. I would like to change the background color of the ggplot depending on the logical vector.
In the example below background_change
is the logical vector.
library(ggplot2)
background_change <- economics$unemploy < 7777
ggplot(economics, aes(date, psavert)) + geom_line()
Note that this is different from other questions posted on stackoverflow which do the background change manually. This is to tedious for my application.