ggplot:根据截距和斜率填充两个 geom_abline 之间的空间

问题描述

如何用颜色填充两条红线之间的空间?

Plot

这是我的增长图数据框中的一个片段,基于来自 Lavaan 的因子得分:

ID  Time Variable   Intercept   Slope
1   1   -0.37924496 -0.43277857 -0.0158650869
2   1   -1.84909928 -1.62877855 0.3286621872
3   1   -0.65797366 -0.78597746 0.4031575259
4   2   -2.17330430 -1.82634938 0.0785367542
5   2   0.21736195  0.53714145  0.9338908763
6   2   1.77226804  1.33300399  0.3201886213
7   3   -2.50918298 -2.26727709 -0.0447654125
8   3   0.78092414  0.80472772  0.2120721960
9   3   -1.21900810 -0.62373325 0.9764875664
10  3   -0.91656612 -0.91447864 -0.3120689584

我从估计的截距和斜率及其置信区间手动添加一个数据框:

growthdf <- data.frame(Intercept = c(-0.074),Slope = c(0.133),i.ci.low = c(-0.173),i.ci.up = c(0.024),s.ci.low = c(0.048),s.ci.up = c(0.218))

到目前为止,这是我的 ggplot:

ggplot(growthplot,aes(x = Time,y = Construct)) +
geom_point(alpha=.0) +
geom_abline(aes(intercept = Intercept,slope = Slope),data = growthplot,alpha=.05) +
geom_abline(aes(intercept = Intercept,data = growthdf,alpha=1) +
geom_abline(aes(intercept = i.ci.low,slope = s.ci.low),alpha=1,color="red") +
geom_abline(aes(intercept = i.ci.up,slope = s.ci.up),color="red")

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)