I`m trying to colour ribbon of complex functions. However, this does not go well (see the figure below):
I want to paint only the lower part of the function. However, in this case, only the part connected by the vertices is painted, and the painted part contains the curve.
My code:
p1 = ggplot(data.frame(x=c(-2.14344,1.25), y=c(0,12.5)),
aes(x, y))
p1 = p1 + stat_function(fun = function(x)(exp( -18.82 + 16.99 * x) + exp(-0.5497 - 0.6572 * x)))
p1 = p1 + xlim(-2.14344,1.25) + ylim(0,12.5)
p1 = p1 + geom_ribbon(fill="blue", alpha = 0.5,
aes(ymax = exp( -18.82 + 16.99 * x) + exp(-0.5497 - 0.6572 * x),
ymin = 0))
print(p1)
I tried to solve this problem and searched for the solutions on Google. But I could not find any suggestion.
If you know any suggestion, please tell me how to solve this. Thanks!