如何在R中的ggplot2中改变箱须图中线的宽度?

时间:2013-09-23 12:14:48

标签: r ggplot2

在当前版本的ggplot2中,与其他行相比,盒须图中的中间线是粗体绘制的:

library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot()

我认为在某些旧版本中并非如此。有没有办法分别调整中线的宽度?

1 个答案:

答案 0 :(得分:8)

Poorly documented,但您可以使用fatten

中的geom_boxplot参数
library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(fatten = 0)

enter image description here

p + geom_boxplot(fatten = 4)

enter image description here