I have plotted grouped boxplots and now I would like to replace the standard black median line with a white line while keeping the borders in an other color. I'm following the instructions on the site Minimalist Boxplots because I really like their style.
They use the command stat_summary(geom = "crossbar", width=0.65, fatten=0, color="white", fun.data = function(x){ return(c(y=median(x), ymin=median(x), ymax=median(x))) })
.
That command worked well with simple boxplots:
But now that I'm trying to use it on my grouped boxplots its not working anymore (white median line is missing):
Here is my the code for reproducing my data:
Data <- data.frame(
W = sample(1:100),
M = sample(1:100),
A = sample(1:100),
O = sample(1:100),
Type = sample(c("1", "2", "3", "4", "5")))
And my script:
Data_Boxplot <- melt(Data,id.vars='Type', measure.vars=c('W','M','A', 'O'))
Boxplots <- ggplot(Data_Boxplot, aes(Type, value, group=variable)) +
geom_boxplot(outlier.colour = NULL, aes(color=variable, fill=variable)) +
stat_summary(geom = "crossbar", width=0.65, fatten=0, color="white",
fun.data = function(x){c(y=median(x), ymin=median(x), ymax=median(x))})
Boxplots
What do I have to change? Thank you very much for your help.