[英]How to remove outlier based on manual threshold in ggplot geom_boxplot
在數據中有hwy <= 10
的行。 出於演示目的,讓我們刪除hwy <= 15
的行。 您可以從 plot 的數據中刪除行。
plt<- ggplot(mpg, aes(class, hwy)) + geom_boxplot(outlier.shape = NA) + geom_jitter(width = 0.2)
plt$data <- subset(plt$data, hwy > 15)
plt
我會過濾數據框,如下所示:
ggplot(mpg %>% filter(hwy >= 10), aes(class, hwy)) + geom_boxplot(outlier.shape = NA) + geom_jitter(width = 0.2)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.