数据
library(ggplot2)
set.seed(123)
df<-data.frame(sid=letters[1:8],
groups=rep(1:4, each=2),
blp=abs(rnorm(8, 120, 5)),
bmi=abs(rnorm(8, 25, 5)),
gender=rep(c("F", "M"), each=4))
方法一
ggplot(df, aes(bmi, blp, color = gender))+
geom_point(size=2)+
facet_grid(sid~groups)

编辑:评论中澄清后的方法2
ggplot(df, aes(bmi, blp, color = gender))+
geom_point(size=2)+
facet_grid(sid~groups)+
geom_rect(data=subset(df, gender == "F"),
aes(xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf),
fill="red", alpha=0.2)+
geom_rect(data=subset(df, gender == "M"),
aes(xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf),
fill="blue", alpha=0.2)
一个更简单的解决方案是+ geom_rect(aes(xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf, fill = gender), alpha=0.2)代替两个geom_rect()s。

警告:正如其他人指出的那样,有一些方法可以制作你的情节风格,但这些方法非常混乱。上述解决方案简单明了,但显然只能填充包含数据的方面。