geom_bspline() 下的填充区域?

Fill area under geom_bspline()?

我看到了如何使用geom_area来填充直线下方的区域。如何填充曲线下方的区域,例如 geom_bspline?

创建的曲线
library("tidyverse")
library("ggforce")

dftest <- tibble(
  x = c(1, 2, 3, 4, 5),
  y = c(10, 15, 30, 80, 5)
)

# Fill area under straight lines - OK
ggplot(dftest, aes(x = x, y = y)) +
  geom_point() +
  geom_line() +
  geom_area(alpha = 0.3)

# Fill area under curve ???
ggplot(dftest, aes(x = x, y = y)) +
  geom_point() +
  geom_bspline() 

您可以使用与区域 geom 配对的统计数据:

ggplot(dftest, aes(x = x, y = y)) +
  geom_point() +
  stat_bspline(geom = "area", alpha = 0.3)