Remove whiskers in box-whisker-plot

后端 未结 2 1096
借酒劲吻你
借酒劲吻你 2020-12-19 03:26

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.

2条回答
  •  無奈伤痛
    2020-12-19 04:03

    We only need to add the argument coef = 0:

    library(ggplot2)
    p <- ggplot(mtcars, aes(factor(cyl), mpg))
    p + geom_boxplot(outlier.shape = NA, coef = 0) # Or outlier.size = -1 instead of outlier.shape = NA
    

    enter image description here

提交回复
热议问题