Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the width of stat_boxplot (errorbar)

Tags:

r

ggplot2

I am using ggplot2 for box ploting.
However, I can't change the width of stat_boxplot (geom ='errorbar').
Here is part of my code:

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

It's OK for geom_boxplot(), but the width of stat_boxplot(geom ='errorbar') is not changed .
Any suggestions? Thank you!

like image 359
good man Avatar asked May 28 '13 16:05

good man


1 Answers

To resize the whiskers lines (width) we can use the argument stat_params = list(width = 0.5) inside the function: 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)) +

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

like image 50
mpalanco Avatar answered Sep 29 '22 11:09

mpalanco