AnjaM AnjaM - 3 years ago 162
R Question

Remove whiskers in box-whisker-plot

Is there a straightforward way to remove the whiskers from a box-whisker-plot in

ggplot2
in
R
? I'd like to keep only the boxes themselves.

MWE:

library("ggplot2")
p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(outlier.size = 0)

Answer Source

We only need to add the argument coef = 0:

library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(outlier.size = 0, coef = 0)

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download