# SCI Figure Hub — Bland-Altman Method Agreement Plot (CC0-1.0) pal <- c("#4DBBD5", "#3C5488", "#E64B35") library(ggplot2) set.seed(14) m1 <- runif(65, 20, 120); m2 <- m1 + rnorm(65, 1.2, 3.8) df <- data.frame(mean = (m1 + m2) / 2, diff = m2 - m1) bias <- mean(df$diff); sd_d <- sd(df$diff) hi <- bias + 1.96 * sd_d; lo <- bias - 1.96 * sd_d p <- ggplot(df, aes(x = mean, y = diff)) + annotate("rect", xmin = -Inf, xmax = Inf, ymin = lo, ymax = hi, fill = pal[1], alpha = 0.10) + geom_hline(yintercept = bias, colour = pal[2], linewidth = 0.65) + geom_hline(yintercept = c(lo, hi), linetype = "dashed", colour = pal[3], linewidth = 0.55) + geom_point(colour = pal[2], size = 1.8, alpha = 0.8) + labs(x = "Mean of Two Methods", y = "Difference (B - A)") + theme_classic(base_size = 8) ggsave("bland_altman.pdf", p, width = 89, height = 64, units = "mm")