-1
To paint the area below the curve, you can use the geom_ribbon
.
The basis has to be reduced to values of x
from the minimum point, in this case 10.
And should be used before geom_line
not to overlap with the line.
library(ggplot2)
ggplot(dat, aes(x = x, y = px)) +
geom_ribbon(
data = subset(dat, x > 10),
aes(ymin = 0, ymax = px),
fill = "blue") +
geom_line()
Can use
geom_area
in place ofgeom_ribbon
, so you don’t need to specify another aesthetic.– Carlos Eduardo Lagosta