I'll start with an MWE:
library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(am)))
p + geom_boxplot()
geom_boxplot
library(Hmisc)
stat_sum_df <- function(fun, geom = "crossbar", ...) {
stat_summary(fun.data = fun, geom = geom, width = 0.4, ...)
}
p + stat_boxplot(geom = 'linerange', colour = "red", position = "dodge) +
stat_sum_df("median_hilow", conf.int = 0.5, position = "dodge")
p + stat_boxplot(geom = 'linerange', colour = "red", position = position_dodge(width = .5)) +
stat_sum_df("median_hilow",conf.int=0.5, position = position_dodge(width = .5))
am
am
width
linerange
width
boxplot
linerange
How about plotting two boxplots on top of each other. One with red lines and a second one on top without any wiskers at all.
p + geom_boxplot(color="red") + geom_boxplot(aes(ymin=..lower.., ymax=..upper..))