我面临一个可能非常容易解决的问题:在散点图中添加对数曲线 . 我已经创建了相应的模型,现在只需要添加相应的曲线/线 .
目前的型号如下:
### DATA
SpStats_urbanform <- c (0.3702534,0.457769,0.3069843,0.3468263,0.420108,0.2548158,0.347664,0.4318018,0.3745645,0.3724192,0.4685135,0.2505839,0.1830535,0.3409849,0.1883303,0.4789871,0.3979671)
co2 <- c (6.263937,7.729964,8.39634,8.12979,6.397212,64.755192,7.330138,7.729964,11.058834,7.463414,7.196863,93.377393,27.854284,9.081405,73.483949,12.850917,12.74407)
### Plot initial plot
plot (log10 (1) ~ log10 (1), col = "white", xlab = "PUSHc values",
ylab = "Corrected GHG emissions [t/cap]", xlim =c(0,xaxes),
ylim =c(0,yaxes), axes =F)
axis(1, at=seq(0.05, xaxes, by=0.05), cex.axis=1.1)
axis(2, at=seq(0, yaxes, by=1), cex.axis=1.1 )
### FIT
fit_co2_urbanform <- lm (log10(co2) ~ log10(SpStats_urbanform))
### Add data points (used points() instead of simple plot() bc. of other code parts)
points (co2_cap~SpStats_urbanform, axes = F, cex =1.3)
现在,我已经完成了所有fit_parameters并且仍然无法为co2_cap(y轴)构建相应的拟合曲线~SpStats_urbanform(x轴)
任何人都可以帮我完成这一小段代码吗?
1 回答
首先,如果要在日志日志空间中绘图,则必须使用参数
log="xy"
指定它:然后,如果要添加回归线,请使用
abline
:Edit :如果你不想_1141015_将你的等式
log10(y)=a*log10(x)+b
翻译成y=10^(a*log10(x)+b)
并用curve
绘制它: