Gregory
Gregory

Reputation: 4279

How to specify equation for regression line in ggplot2?

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.

Upvotes: 1

Views: 6651

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226961

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.

Upvotes: 5

Related Questions