我正在使用ggplot2进行盒子绘图.
但是,我无法更改stat_boxplot的宽度(geom ='errorbar').
这是我的代码的一部分:
geom_boxplot(width=0.5)+stat_boxplot(geom ='errorbar',width=0.5)
Run Code Online (Sandbox Code Playgroud)
没关系geom_boxplot(),但宽度stat_boxplot(geom ='errorbar')不会改变.
有什么建议?谢谢!
要调整胡须线(宽度)的大小,我们可以使用函数stat_params = list(width = 0.5)内部的参数:stat_boxplot
library(ggplot2)
ggplot(iris, aes(factor(Species), Sepal.Width, fill = Species)) +
geom_boxplot() +
stat_boxplot(geom ='errorbar', stat_params = list(width = 0.5)) +
Run Code Online (Sandbox Code Playgroud)
更新
现在我们可以使用width里面的参数stat_boxplot
library(ggplot2)
ggplot(iris, aes(factor(Species), Sepal.Width, fill = Species)) +
geom_boxplot() +
stat_boxplot(geom ='errorbar', width = 0.5)
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
4975 次 |
| 最近记录: |