A previous post describes how to draw red circles around points which exceed a given value in ggplot. I would like to do the same for anomaly detection results, but instead have the circles drawn around points belonging to a given factor level.
How could I change this code to allow circles to be drawn around a given factor level?
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
geom_point(data=mtcars[mtcars$mpg>30,],
pch=21, fill=NA, size=4, colour="red", stroke=1) +
theme_bw()