这里有一个简化,可以让生活更轻松。唯一需要做的就是从提供给背景geom_point()
层的数据中移除分面变量。
library(tidyverse)
ggplot(data=mtcars, aes(x=mpg, y=wt)) +
geom_point(data=select(mtcars,-cyl), colour="grey") +
geom_point(size=2, pch=21, aes(fill=factor(cyl))) +
scale_fill_manual(values=c("red","orange","blue")) +
facet_wrap(~cyl)