ggplot - make the median invisible geom_boxplot
Asked Answered
B

1

5

for some obscure reason, I must draw a boxplot with no apparent median. How can I achieve this (using ggplot is preferred, but if it is necessary I will switch to boxplot) please?

Related answers:

  • use fatten parameter: I tried setting the fatten parameter to 0, following this answer. A thin line remains.
  • use geom_segment : I tried to superpose a white segment onto the median using this method. But superposing a white segment onto the median line is unsatisfactory because the edges of the box are also erased. I think this approach would work using boxplot though, since, as can be seen here it is possible to change the median's color without affecting the edges of the box.
Bunyip answered 15/5, 2017 at 14:20 Comment(2)
flatten = 0 works for me, packageVersion('ggplot2') # [1] ‘2.2.1’Marje
You could also try thisQuiet
D
9

One kind of "hacky" way to do this would be use the fatten argument in the answer you posted, but set it equal to NULL. Note since you didn't post any data, I used mtcars a built in R dataset. This would look like:

library(ggplot2)
ggplot(data = mtcars) + geom_boxplot(aes(x = as.factor(am), y = hp), fatten = NULL)

enter image description here

Dublin answered 15/5, 2017 at 14:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.