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.
Community
  • 1
  • 1
hartmut
  • 934
  • 12
  • 25

1 Answers1

8

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

Mike H.
  • 13,960
  • 2
  • 29
  • 39