I tried to find the possibilities how to shade the area between two lines in ggplot that are defined by function. I found some solutions using geom_area or geom_ribbon but in both cases you need a database in which you define ymin and ymax. Is there any other possibility? In the way that the ymin and ymax are defined also with same functions as the lines?
Here is my exsample:
myplot <- ggplot(data.frame(x=c(0, 100)), aes(x=x)) +
stat_function(fun= function(x)20*sqrt(x), geom="line", colour= "black", size= 1) +
stat_function(fun= function(x)50*sqrt(x), geom="line", colour= "black", size= 1)
myplot
Thank you for your help in advance.