How to change the mustache line thickness using stat_boxplot (geom = "errorbar")

I would like to change the thickness of the mustache line when using stat_boxplot(geom = "errorbar"):

set.seed(42)
df <- data.frame(cond = factor( rep(c("A","B"), each=500) ), 
  value = c(rnorm(500,mean=1,sd=0.2),rnorm(500, mean=1.5,sd=0.1)))
ggplot(df, aes(x=cond, y=value)) + geom_boxplot(lwd=0.2)
ggplot(df, aes(x=cond, y=value)) + 
      stat_boxplot(geom = "errorbar", 
       stat_params = list(width = 0.5,size = 5.0)) + 
      geom_boxplot(lwd=0.2)

In the second figure lwd=0.2, the thickness of the lines in the box changes, but the mustache remains unchanged.

enter image description here enter image description here

Update

Thanks @ eipi10,

ggplot(df, aes(x=cond, y=value)) + stat_boxplot(geom = "errorbar",
    width = 0.5, size=0.2) + geom_boxplot(lwd=0.2)

your decision changes the thickness of the lines of the mustache, but makes a horizontal line at its end with a width rather than half (width = 0.5).

But using

ggplot(df, aes(x=cond, y=value)) + stat_boxplot(geom ="errorbar",
    stat_params = list(width = 0.5), size=0.2) + geom_boxplot(lwd=0.2)

or

ggplot(df, aes(x=cond, y=value)) + stat_boxplot(geom = "errorbar",
    stat_params = list(width = 0.5, size=0.2)) + geom_boxplot(lwd=0.2)

then the width of the whiskers is half the field, as expected, but their default line thickness is thicker than the window line.

In other words, I cannot simultaneously change the thickness of the lines and the width of the mustache.

Update two

I get the same result with these two pieces of code (both without stat_params)

ggplot(df, aes(x=cond, y=value)) + stat_boxplot(geom = "errorbar",
    width=0.5, size=5) + geom_boxplot(lwd=0.2)

ggplot(df, aes(x=cond, y=value)) + stat_boxplot(geom = "errorbar",
    width=0.2, size=5) + geom_boxplot(lwd=0.2)

enter image description here enter image description here

Jose

+4
2

, , , :

ggplot(df, aes(x=cond, y=value)) + 
  stat_boxplot(geom = "errorbar", width=0.5, size=5) +
  geom_boxplot(lwd=0.2)

width:

enter image description here

+6

ggplot(df, aes(x=cond, y=value)) + stat_boxplot(geom = "errorbar", 
stat_params = list(width = 0.5), geom_params = list(size = 2))
+geom_boxplot(size = 2)
0

Source: https://habr.com/ru/post/1607159/


All Articles