ggplot(data.frame(x = c(-3, 7)), aes(x)) +
stat_function(fun = dnorm, args = list(mean = 0, sd = 1),
geom = "polygon",
alpha = 0.3,
fill = "blue") +
stat_function(fun = dnorm, args = list(mean = 2, sd = 1),
geom = "polygon",
alpha = 0.3,
fill = "red") +
stat_function(fun = dnorm, args = list(mean = 4, sd = 1),
geom = "polygon",
alpha = 0.3,
fill = "forestgreen") +
ylim(0,.5) +
scale_x_continuous(breaks = -3:7) +
labs(x = "X", y = "") +
annotate("text", x = 0, y = 0.2, label = "Group 1", color = "blue") +
annotate("text", x = 2, y = 0.2, label = "Group 2", color = "red") +
annotate("text", x = 4, y = 0.2, label = "Group 3", color = "forestgreen") +
annotate("segment", x = 0, xend = 1.95, y = .4, yend = .4,
arrow = arrow(ends = "both", angle = 90, length = unit(.2,"cm"))) +
annotate("text", x = 2, y = .47, label = "Differences?") +
annotate("segment", x = 2.05, xend = 4, y = .4, yend = .4,
arrow = arrow(ends = "both", angle = 90, length = unit(.2,"cm"))) +
annotate("segment", x = 0, xend = 4, y = .43, yend = .43,
arrow = arrow(ends = "both", angle = 90, length = unit(.2,"cm")))