I have a dataset named mpg. I am interested in plotting a boxplot (with points on it) to see the relationship between the variable drv (types of drive train) and the cty (city miles per gallon).
Below is my code:
ggplot(data=mpg,mapping=aes(x=drv,y=cty))+geom_boxplot(outlier.shape = NA)+geom_jitter()
Is there a way to exclude the outliers from geom_jitter() ?
geom_jitter()
does not have argument for discarding the outliers by its own. You have to manually filter the data points to be plotted or manually define which points are outliers before feeding it into thegeom_jitter()
. – Nuclear03020704