[英]Plotting geom_smooth/geom_spline regression line through the origin
[英]Plotting a regression line through the origin
我正在使用此代碼繪制一些數據系列以及回歸線:
ggplot(dt1.melt, aes(x=lower, y=value, group=variable, colour=variable)) +
geom_point(shape=1) +
geom_smooth(method=lm,
se=FALSE)
但是,我需要將回歸線約束為通過所有系列的原點 - 與abline(lm(Q75~-1+lower,data=dt1))
在標准R圖上實現的方式相同。
任何人都可以解釋如何在ggplot
這樣做嗎?
您需要在geom_smooth
的formula
參數中指定它:
... + geom_smooth(method=lm, se=FALSE, formula=y~x-1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.