How to specify equation for regression line in ggp

2019-07-22 20:31发布

问题:

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.

回答1:

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.



标签: r ggplot2