11

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!

eddi
  • 49,088
  • 6
  • 104
  • 155
good man
  • 339
  • 6
  • 15
  • 1
    file a bug report, in the meanwhile you can use the second solution here: http://stackoverflow.com/questions/12993545/how-to-put-whisker-ends-on-ggplot2-boxplot/13003038 – eddi May 28 '13 at 22:02

1 Answers1

5

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

mpalanco
  • 12,960
  • 2
  • 59
  • 67
  • 1
    This no longer works for newer version ggplot2. `stat_boxplot` has `width` parameter now. – mt1022 Feb 23 '17 at 14:23