所以我有一个像这样的数据框:
a_data <-
data.frame(
f = f,
alpha = alpha,
asymptote = alpha_1_est)
Run Code Online (Sandbox Code Playgroud)
和这样的功能:
a_formula <- function(x) {
0.7208959 - 0.8049132 * exp(-21.0274 * x)}
Run Code Online (Sandbox Code Playgroud)
我将它们与ggplot2结合使用:
ggplot(a_data, aes(x = f, y = alpha)) +
geom_point() +
#function curve
stat_function(fun = a_formula,
color = "red") +
#asymptote of alpha
geom_hline(
yintercept = asymptote,
linetype = "longdash",
color = "blue")
Run Code Online (Sandbox Code Playgroud)
我想要并且找不到的方法是对y轴,函数曲线(红色)和渐近线(虚线)之间的区域进行着色,如下所示:

我尝试在其中挤压功能区或多边形,但无法正常工作-可能是因为我想在曲线上方而不是下方着色(下面的效果很好)。
数据框如下所示:
> head(a_data)
f alpha asymptote
1 0.01 0.007246302 0.7208959
2 0.03 0.374720198 0.7208959
3 …Run Code Online (Sandbox Code Playgroud)