until now I can't find an appropriate answer, here is my short question about ggplot2 in R:
data(mtcars)
ggplot(data=mtcars, aes(x=mpg, y=wt, fill=factor(cyl))) +
scale_fill_manual(values=c("red","orange","blue"))+
geom_point(size=2, pch=21)+
facet_grid(.~cyl)
This is all fine, now I want all data points (regardless what number cyl has) in every facet (e.g. with a smooth grey below the points)?
Thanks, Michael
Here is a slight simplification that makes life a bit easier. The only thing you need to do is to remove the faceting variable from the data provided to the background geom_point()
layer.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With