I want to add a single point to only one facet. I tried to set the group in geom_point:
ggplot(data=mpg, aes(displ, hwy))
geom_point()
facet_wrap(~class) geom_point(aes(x=5, y=25, group = "pickup"), colour="blue")
But that put a blue dot in all facets. Is there any way to constrain the point to only one?
CodePudding user response:
You could achieve your desired result by putting the information for your point in a dataframe which you pass to the data
argument of your second geom_point
:
library(ggplot2)
ggplot(data=mpg, aes(displ, hwy))
geom_point()
facet_wrap(~class)
geom_point(data = data.frame(displ = 5, hwy = 25, class = "pickup"), colour="blue")