R – Adding stat_smooth in to only 1 facet in ggplot2


I have some data for which, at one level of a factor, there is a significant correlation. At the other level, there is none. Plotting these side-by-side is simple. Adding a line to both of them with stat_smooth, also straightforward. However, I do not want the line or its fill displayed in one of the two facets. Is there a simple way to do this? Perhaps specifying a blank color for the fill and colour of one of the lines somehow?

Best Solution

Don't think about picking a facet, think supplying a subset of your data to stat_smooth:

ggplot(df, aes(x, y)) +
  geom_point() + 
  geom_smooth(data = subset(df, z =="a")) + 
  facet_wrap(~ z)
Related Question