忽略ggplot2 boxplot中的异常值

我如何忽略ggplot2 boxplot中的离群值?我不只是希望它们消失(即outlier.size = 0),而是希望它们被忽略,以便y轴缩放以显示第一/第三百分位数。我的异常值导致“框”缩小到几乎成一条线的程度。有一些技巧可以解决这个问题吗?


编辑 这是一个例子:


y = c(.01, .02, .03, .04, .05, .06, .07, .08, .09, .5, -.6)

qplot(1, y, geom="boxplot")


扬帆大鱼
浏览 2596回答 3
3回答

潇潇雨雨

我有同样的问题,并使用以下方法预先计算了Q1,Q2,中位数,ymin,ymax的值boxplot.stats:# Load package and generate datalibrary(ggplot2)data <- rnorm(100)# Compute boxplot statisticsstats <- boxplot.stats(data)$statsdf <- data.frame(x="label1", ymin=stats[1], lower=stats[2], middle=stats[3],&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;upper=stats[4], ymax=stats[5])# Create plotp <- ggplot(df, aes(x=x, lower=lower, upper=upper, middle=middle, ymin=ymin,&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ymax=ymax)) +&nbsp;&nbsp; &nbsp; geom_boxplot(stat="identity")p
打开App,查看更多内容
随时随地看视频慕课网APP