I have two probability distribution curves, a Gamma and a standarized Normal, that I need to compare:
library(ggplot2) pgammaX <- function(x) pgamma(x, shape = 64.57849, scale = 0.08854802) f <- ggplot(data.frame(x=c(-4, 9)), aes(x)) + stat_function(fun=pgammaX) f + stat_function(fun = pnorm)
The output is like this However I need to have the two curves separated by means of the faceting mechanism provided by ggplot2, sharing the Y axis, in a way like shown below:
I know how to do the faceting if the depicted graphics come from data (i.e., from a data.frame), but I don't understand how to do it in a case like this, when the graphics are generated on line by functions. Do you have any idea on this?