将coef设置为5,stats <- quantile(x, probs = c(0, 0.25, 0.5, 0.75, 1)),如果没有fact,直接在 geom_boxplot(coef = 5)。
calc_stat <- function(x) { coef <- 5 n <- sum(!is.na(x)) # calculate quantiles stats <- quantile(x, probs = c(0, 0.25, 0.5, 0.75, 1)) names(stats) <- c("ymin", "lower", "middle", "upper", "ymax") return(stats) } p = ggplot(plot_data, aes(x = method, y = value, fill = method),coef = 5) + #geom_boxplot(coef = 5) + stat_summary(fun.data = calc_stat, geom="boxplot") + facet_wrap(~metric, scales = "free") + theme_bw()+ theme(legend.position = "bottom", panel.grid = element_blank(), axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5), axis.title = element_blank()) p