r - ggplot:根据截距和斜率填充两个geom_abline之间的空间
问题描述
你将如何用两条红线之间的颜色填充空间?
这是我根据 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, slope = Slope), data = growthdf,alpha=1) +
geom_abline(aes(intercept = i.ci.low, slope = s.ci.low), data = growthdf,alpha=1, color="red") +
geom_abline(aes(intercept = i.ci.up, slope = s.ci.up), data = growthdf,alpha=1, color="red")
解决方案
推荐阅读
- matlab - fft 的不同绘图形状取决于时间样本间距
- html - div未按顺序显示
- php - 过滤查询无法通过 Laravel 查询生成器工作
- excel - 有没有办法在 Excel 中对“除此之外的所有内容”进行条件格式设置
- r - 在R中的森林图中(metafor包)减少`xlab`和x轴之间的空间
- pdfbox - Apache Tika 输出中的未定义字符替换文本(例如“ti”、“fb”)
- r - 如何在 R 中 left_join 并将值重复加入多个变量?
- machine-learning - 2.3 Pytorch BCEloss与我自己的“log”计算的比值
- python - 具有持续时间的总和列 (HH:MM:SS)
- neo4j - neo4j 创建子节点并将其链接到另一个子节点