First off, I like your approach; not sure whether this is less "hackey", but here's another option using gghighlight
# Generate data (see comment below)
library(dplyr)
df <- data.frame(x = seq(-5, 5, length.out = 100)) %>% mutate(y = dnorm(x))
# (gg)plot and (gg)highlight
library(ggplot2)
library(gghighlight)
ggplot(df, aes(x, y)) + geom_area(fill = "sky blue") + gghighlight(x < -1.35)

From what I understand, gghighlight
needs a data
argument, so it won't work with geom_area
by itself (meaning: without data
but with stat = "function"
), or with stat_function
. That's why I'm generating data df
first.
Update
In response to your comment about how to "highlight the area between 1 and -1"; you can do the following
ggplot(df, aes(x, y)) + geom_area(fill = "sky blue") + gghighlight(abs(x) < 1)

Update 2
To highlight the region 1.5 < x < 2.5
simply use the conditional statement x > 1.5 & x < 2.5
ggplot(df, aes(x, y)) + geom_area(fill = "sky blue") + gghighlight(x > 1.5 & x < 2.5)

To pre-empt potential follow questions: This method will only work for contiguous regions. Meaning, I haven't found a way to highlight x < -2.5 & x > 2.5
in a single gghighlight
statement.