Can I change the background for some values for the faceting?
I have 50 plots in the faceting plot. I wonder if I can highlight some of them by changing the background for the selected plots.
Specifically, the picture below is my ggplot outcome right. I want to highlight 37& 42 by coloring their background as lightblue.
I thought about using ifelse
. But I am not sure how to define the control flow.
below is my code
axr_treat_ctrl %>%
ggplot(aes(x= year, y= mtopic,colour= Type,group=Type))+
geom_line( )+
geom_point( size= 1) +
scale_y_continuous(breaks = extended_breaks(n = 5) )+
scale_x_continuous(breaks = extended_breaks(n = 10) )+
geom_vline(xintercept = 2005,linetype=2,color= "brown")+
geom_vline(xintercept = c(2010,2011,2017),linetype=3,color= "blue")+
labs(x= "x-axis",
y ="y-axis ")+
facet_wrap(~topicr )+
guides(x = guide_axis(angle = 90))+
theme(legend.position = "bottom")
# ifelse ( topicr==37, call( expr(panel.background = element_rect(fill = "lightblue"))),
# call( expr( panel.background = element_rect(fill = "white") ))) )