How do you specify different geoms for different facets in a ggplot?
(Asked on behalf of @pacomet, who wanted to know.)
here is another approach by subsetting data:
ggplot(mtcars, aes(mpg, disp)) + facet_wrap(~cyl) + geom_point(data = subset(mtcars, cyl == 4)) + geom_line(data = subset(mtcars, cyl == 6)) + geom_text(data = subset(mtcars, cyl == 8), aes(label = gear))
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