library(tidyverse)
density(rnorm(1000, 0, 1)) %$%
data.frame(x=x, y=y) %>%
mutate(area = dplyr::between(x, 1.5, 2.6)) %>%
ggplot(aes(x = x, ymin = 0, ymax = y)) +
geom_ribbon(aes(fill = "Outside")) +
geom_ribbon(aes(fill = "Inside"), data = function(df) df %>% filter(area))
结果: