【发布时间】:2019-08-04 07:49:36
【问题描述】:
我试图在一个绘图上比较和对比具有相似 x 轴的四个关系之间的差异。
我似乎可以绘制回归线,但不知道如何绘制方程和/或将所有四个图合并为一个。
这是我的代码的基本基础:对不起,如果它非常基础或笨拙,我才刚刚开始。
library(ggplot2)
library(cowplot)
p1 <- ggplot(NganokeData, aes(x=Depth,y=LCU1)) + geom_point() +
labs(x ='Depths (cm)', y ='Density (Hu)', title = 'Density Regression of Lake Nganoke Core 1') +
ylim(1,2)
p2 <- ggplot(NganokeData, aes(x=Depth,y=LCU2)) + geom_point() +
labs(x ='Depths (cm)', y ='Density (Hu)', title = 'Density Regression of Lake Nganoke Core 2') +
ylim(1,2)
p3 <- ggplot(NganokeData, aes(x=Depth,y=LCU3)) + geom_point() +
labs(x ='Depths (cm)', y ='Density (Hu)', title = 'Density Regression of Lake Nganoke Core 3') +
ylim(1,2)
p4 <- ggplot(NganokeData, aes(x=Depth,y=LCU4)) + geom_point() +
labs(x ='Depths (cm)', y ='Density (Hu)', title = 'Density Regression of Lake Nganoke Core 4') +
ylim(1,2)
p3 + stat_smooth(method = "lm", formula = y ~ poly(x, 3), size = 1) #Adds polynomial regression
【问题讨论】:
标签: r ggplot2 regression polynomials