如何在ggplot2中指定回归线的方程? [英] How to specify equation for regression line in ggplot2?

查看:163
本文介绍了如何在ggplot2中指定回归线的方程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在ggplot2中创建一个或多个覆盖线的散点图。查看了geom_smooth()和geom_line()的文档后,我仍不清楚如何指定要添加到图的线的方程式。我明白这一定是非常基本的,所以请随时简单地指出我必须忽略的适当文件。 解决方案

p> geom_abline()是您要查找的geom的名称,例如 geom_abline(AES(截距= A,斜率= b))的在线文档中有一些示例。


I want to create a scatterplot in ggplot2 with one or more lines over-layed. Having looked at the documentation for geom_smooth() and geom_line(), it remains unclear to me how I can specify the equations for lines that I want to add to a plot. I understand that this must be very basic, so please feel free simply to point me toward the appropriate documentation that I must have overlooked.

解决方案

geom_abline() is the name of the geom you're looking for, e.g. geom_abline(aes(intercept=a,slope=b)). There are examples in the online documentation.

这篇关于如何在ggplot2中指定回归线的方程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆