如何改变stat_boxplot(误差条)的宽度

11

我正在使用ggplot2来制作箱线图。
然而,我无法更改stat_boxplot(geom ='errorbar')的宽度。
这是我的代码的一部分:

geom_boxplot(width=0.5)+stat_boxplot(geom ='errorbar',width=0.5)

geom_boxplot() 没问题,但是 stat_boxplot(geom='errorbar') 的宽度没有改变。
有什么建议吗?谢谢!


1
提交一个错误报告,同时您可以使用这里的第二个解决方案:https://dev59.com/R2cs5IYBdhLWcg3wRB3h#13003038 - eddi
1个回答

5

要调整胡须线的大小(宽度),我们可以在函数stat_boxplot内使用参数stat_params = list(width = 0.5)

library(ggplot2)
ggplot(iris, aes(factor(Species), Sepal.Width, fill = Species)) +
  geom_boxplot() + 
  stat_boxplot(geom ='errorbar', stat_params = list(width = 0.5)) +

Update

Now we can use the argument width inside stat_boxplot

library(ggplot2)
ggplot(iris, aes(factor(Species), Sepal.Width, fill = Species)) +
  geom_boxplot() + 
  stat_boxplot(geom ='errorbar', width = 0.5) 

enter image description here


1
这个在新版本的ggplot2中已经不再适用了。现在stat_boxplot有一个width参数。 - mt1022

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接