Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206278

Draw circles around points belonging to a factor level in ggplot

$
0
0

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()

Viewing all articles
Browse latest Browse all 206278

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>